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 ➜ General ➜ Checking some aliases before others?

Checking some aliases before others?

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


Posted by Sleeve   (31 posts)  Bio
Date Thu 06 Mar 2003 08:08 AM (UTC)
Message
I have an alias "addspell <spellname>:<duration>:<spellgroup>" and want to add another version of it "addspell <spellname>" that call some small script routines. So I made an alias addspell * and have addspell *:*:*. But now whenever I type "addspell a:b:c" it is always checked by addspell * instead of addspell *:*:*. I know I can just change the alias to be something else so it doesn't "conflict" but I was wondering if there was a sequence number type thing for aliases (like there are for triggers) to always check the addspell *:*:* alias before it checks addspell *?
Top

Posted by Loki   (44 posts)  Bio
Date Reply #1 on Thu 06 Mar 2003 07:42 PM (UTC)
Message
Why don't you just rename them to:

addspell <spellname>:<duration>:<spellgroup>"
and
addspell2 *

-LºKi_
Founder
Endless Dreams
Top

Posted by Krenath   USA  (76 posts)  Bio
Date Reply #2 on Thu 06 Mar 2003 09:38 PM (UTC)
Message
Why not just have a single alias, ADDSPELL *, and have a script examine the parameters and determine what steps to perform?

Check for the presence of a : (or use the split() function to split the parameter string on colons and check to see how many elements are in the resulting array.) and take the appropriate action.



- Krenath from
bDv TrekMUSH
ATS TrekMUSH
TNG TrekMUSE
TOS TrekMUSE
Top

Posted by Shadowfyr   USA  (1,790 posts)  Bio
Date Reply #3 on Thu 06 Mar 2003 10:45 PM (UTC)
Message
Hmm. With that in mind..

Alias> addspell (.*)\:?(.*)?\:?(.*)?
Regexp> Yes

That should pass either 1, or 2 or 3 parameters, depending on how many you use and all you then have the code test to see if the second and third ones are empty and treat them accordingly. Thus you could have:

addspell <spellname>
addspell <spellname>:<durarion>
or addspell <spellname>:<duration>:<spellgroup>

I am not 100% sure the above regex is right. Technically ?: is a special command, but :? isn't, so I am assuming that you have to escape (add a \) the : for it to work, but the regular expression docs lack something as useful and simple as an actually list of all special characters that need to be used as \<character>, though it does go into excruciating detail on how to use various special characters... lol All you can do is try and see if it does what you want. ;)
Top

Posted by Sleeve   (31 posts)  Bio
Date Reply #4 on Fri 07 Mar 2003 12:40 AM (UTC)
Message
Thanks for the help everyone. I ended up going with Krenath's suggestion of using split and seeing how many arguments were passed and parsing it from there. Don't know why I didn't think of that... thanks again. :)
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.


17,227 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.