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 *?
Checking some aliases before others?
Posted by Sleeve on Thu 06 Mar 2003 08:08 AM — 5 posts, 22,737 views.
Why don't you just rename them to:
addspell <spellname>:<duration>:<spellgroup>"
and
addspell2 *
addspell <spellname>:<duration>:<spellgroup>"
and
addspell2 *
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.
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.
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. ;)
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. ;)
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. :)