the lazy alias (a true story)

Posted by RashinLord on Thu 08 Dec 2005 06:57 AM — 3 posts, 13,756 views.

Canada #0
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?
Amended on Thu 08 Dec 2005 09:35 AM by Nick Gammon
Australia Forum Administrator #1
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.
Australia Forum Administrator #2
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.