|
rtatum Novice
Joined: 19 Sep 2004 Posts: 45 Location: Houston
|
Posted: Fri Oct 22, 2004 3:10 am
Help with a simple alias |
Okay, I've written an alias called "increase" that will simplify having to type out increase x multiple times... basically when one of my units gets a level, I get to spend points to raise it's stats, i.e. I get 10 points a level, and then I spend them as I see fit, like increase attack, increase defense, increase hp, increase mp, increase speed, et cetera...
So what I've done is write this simple alias called increase, and here's what it does:
#IF (%isnumber( %1)) {#EXEC ~#%1 ~increase %2} {~increase %1 %2}
If I type increase 2 attack, it responds by sending increase attack, increase attack, but if I want to say, increase attack, increase defense, and increase hp, then I want to be able to type increase att def hp, and have it send increase attack, increase defense, increase hp... preferably accepting 5 or more, unlimited would be good as well... another point, I want to be able to use increase def, and have it send out the unabbreviated word, defense, as I indicated above, any help on this would be greatly appreciated, ideas are always welcome, thanks for your time and help |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Fri Oct 22, 2004 9:59 am |
#ALIAS increase {Raising=%replace("%-1"," ","|");#WHILE (@Raising) {#IF (%isnumber(%item(@Raising,1))) {#LOOP %pop(Raising) {~increase %item(@Raising,1)};#DELNITEM Raising 1} {~increase %pop(Raising)}}
I didn't do the abbreviation expansion, just don't have time in the mornings. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
rtatum Novice
Joined: 19 Sep 2004 Posts: 45 Location: Houston
|
Posted: Fri Oct 22, 2004 2:33 pm |
I think I can handle the abrreviation expansion, thanks for the help Vijilante
|
|
|
|
rtatum Novice
Joined: 19 Sep 2004 Posts: 45 Location: Houston
|
Posted: Fri Oct 22, 2004 7:20 pm |
Problem... I've been encountering this problem recently when I've been writing aliases and triggers using the command line... I'll write #TRIGGER {blah blah blah} {#EXEC blah blah blah} and the pattern sometimes get's messed up, adding in the {} brackets, and the value will be "{#EXEC" with nothing else, and so when the pattern hits, it sends {#EXEC to the mud, this same problem just happened with the alias you wrote for me Vijilante, can anyone shed some light on this please?
|
|
|
|
Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: Fri Oct 22, 2004 7:42 pm |
This usually happens when you miscount the number of brackets {}.
Add one more } on the end of Vijilante's alias:
#ALIAS increase {Raising=%replace("%-1"," ","|");#WHILE (@Raising) {#IF (%isnumber(%item(@Raising,1))) {#LOOP %pop(Raising) {~increase %item(@Raising,1)};#DELNITEM Raising 1} {~increase %pop(Raising)}}}
As for it causing the same problem with #TRIGGER {blah blah blah} {#EXEC blah blah blah}, that is highly unlikely =P |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Fri Oct 22, 2004 10:04 pm |
Yep I was missing a closing brace. Guess that is what happens when I answer questions on only my second cup of coffee. The extras of the way I did that alias are that it can handle inputs like:
increase 2 attack 3 defense hp 7 other
If you can't add the abbreviation handling just give a post and I will put it in. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|