|
NitroGlycerine Beginner
Joined: 26 Apr 2007 Posts: 29
|
Posted: Thu Apr 26, 2007 4:16 pm
expanding variables |
I have an alias with this code:
#additem testlist %1
#alarm +1 {#delitem testlist %1}
Basicly add an item to a list and remove it 1 second later.
In ZMUD this used to work if I used #delitem testlist <%1>.
However this ain't possible in CMUD anymore. I tried without <> in CMUD, but it doesn't work either.
Any suggestions on how to get this working? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Apr 26, 2007 4:22 pm |
<> has been removed - check out the help section Changes for zMUD Users. You don't need to use <> in this situation - the code you have there should work fine.
|
|
|
|
NitroGlycerine Beginner
Joined: 26 Apr 2007 Posts: 29
|
Posted: Thu Apr 26, 2007 4:36 pm |
It doesn't work.
But I found out how to get it working using a local variable, not really an elegant solution though:
$tempvar=%1
#additem testlist $tempvar
#alarm +1 {#delitem testlist $tempvar} |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Apr 26, 2007 5:48 pm |
You're right, it doesn't work. Localvars are the way to do it - either that way, or by directly making the localvar the parameter of the alias. Either add it to the params box manually, or create the alias using the syntax:
#alias test($param1,$param2) {whatever} |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Apr 26, 2007 6:18 pm |
The problem is that an #ALARM is really a trigger, so your %1 in the alarm is actually trying to refer to the first pattern matched by the trigger...just like using %1 in any other normal trigger. So %1 in the alarm isn't referring to the %1 argument for the alias.
As Fang mentioned, the correct way to do this is via named arguments for your alias:
Code: |
#ALIAS test($arg) {
#additem testlist $arg
#alarm +1 {#delitem testlist $arg}
} |
|
|
|
|
NitroGlycerine Beginner
Joined: 26 Apr 2007 Posts: 29
|
Posted: Thu Apr 26, 2007 9:48 pm |
Thanks for the help.
It works perfect now! |
|
|
|
|
|