Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
NitroGlycerine
Beginner


Joined: 26 Apr 2007
Posts: 29

PostPosted: 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?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
Reply with quote
NitroGlycerine
Beginner


Joined: 26 Apr 2007
Posts: 29

PostPosted: 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}
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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}
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: 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}
  }
Reply with quote
NitroGlycerine
Beginner


Joined: 26 Apr 2007
Posts: 29

PostPosted: Thu Apr 26, 2007 9:48 pm   
 
Thanks for the help.

It works perfect now! Very Happy
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net