Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ the lazy alias (a true story)

the lazy alias (a true story)

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


Posted by RashinLord   Canada  (29 posts)  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?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  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
Top

Posted by Nick Gammon   Australia  (23,173 posts)  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
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.


13,067 views.

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

Go to topic:           Search the forum


[Go to top] top

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