[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  the lazy alias (a true story)
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

the lazy alias (a true story)

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by RashinLord   Canada  (29 posts)  [Biography] bio
Date Thu 08 Dec 2005 06:57 AM (UTC)

Amended on Thu 08 Dec 2005 09:35 AM (UTC) by Nick Gammon

Message
Ok. Hello.

I've a long list (About 300) of spells/skills that I want to alias out.

Heres an example:
---

<alias 
  match="armor" 
  enabled="y">  	
  <send>c armor</send>
</alias>

---
Now that's just dandy since I like to cast armor on myself.
As most ROM based muds do, my muds "cast" function takes in 2 arguments, the spell, and the target. With all protection spells the default is yourself when no target argument is supplied. With other types of spells the defaults vary from random portals to attack type spells hitting only the player/mobile that you're in combat with.

Here is my problem; I want a single alias for a spell without an argument (EG. cast armor) and one with an argument (EG. cast armor nick).

I find matching on MUSH to be quite different than what I'm used to, which is wintin. On wintin, if I wanted to have this same alias it would be #alias {armor}{c armor}.

Wintin would match me entering "armor" so they would send "c armor" to the mud. However, if I entered
"armor stupid dumb troll with big boots"
it would send
"c armor stupid dumb troll with big boots"

Can anybody help me out?
[Go to top] top

Posted by Nick Gammon   Australia  (21,607 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 08 Dec 2005 09:37 AM (UTC)
Message
That's easily fixed. You want a wildcard next to it:


<aliases>
  <alias
   match="armor*"
   enabled="y"
   sequence="100"
  >
  <send>c armor%1</send>
  </alias>
</aliases>


That does what you require.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (21,607 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Thu 08 Dec 2005 10:17 AM (UTC)
Message
Also, rather than making 300 aliases, you might be able to simplify things, if they follow a pattern. eg.


<aliases>
  <alias
   match="^(armor|shield|heal)(.*?)$"
   enabled="y"
   regexp="y"
   sequence="100"
  >
  <send>c %1%2</send>
  </alias>
</aliases>


This single alias will handle armor/shield/heal cast on yourself or someone else.

Or, to get more elaborate again, you can map long spells into shorter ones. This example, which uses a small bit of inline scripting in Lua (sorry, I know it is the wrong section of the forum) shows how you can type "cc" and have it translate to "cure critical" in a simple table lookup.

If you want to stick to VBscript you could achieve the same thing in a different (harder) way. :)


<aliases>
  <alias
   match="^(armor|shield|heal|cl|cs|cc)(.*?)$"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

replacements = {
  cl = "cure light",
  cs = "cure serious",
  cc = "cure critical",
  }

Send ("c '" .. (replacements ["%1"] or "%1") .. "'%2")
</send>
  </alias>
</aliases>



Above you see a "replacements" table which maps what you typed in the alias to what you want sent. Anything not found is sent "as is" so things like "armor" don't need a table entry.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


2,927 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]