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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
glowack2
Newbie


Joined: 26 Oct 2002
Posts: 5
Location: USA

PostPosted: Sun Oct 05, 2003 6:44 pm   

Variable expansion
 
OK, I'm having a hell of a time with getting variables to expand properly. I've read the docs, read the forums, tried about a million different things and nothing seems to work.

Essentially I have something like this:

#forall @items {
itemcolor = set-by-a-big-bunch-of-irrelevant-code
#echo %i @itemcolor
#trigger {%i} {#cw @itemcolor} {Color highlighting}
}

What happens when this:
The #echo line correctly displays the trigger text and expands @itemcolor each time through the loop, so we end up with each item followed by a different color name. The #trigger line creates the correct trigger, but the value of the trigger is *always* "#cw @itemcolor". Note that the variable is not expanded. I tried enclosing @itemcolor in <> to get it to expand, but then it only seems to expand ONCE, and every trigger becomes "#cw red". So how do I get the middle ground, so that every time through the loop I can expand @itemcolor and get the proper color put into the trigger I'm creating?

Thanks!
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Oct 05, 2003 11:03 pm   
 
Everything is working right. The problem your having is that the #TRIGGER command is not supposed to expand anything. This is done so that triggers can be created with a script that will work. You work around this by use of the #EXEC command:
#EXEC {%concat("#trigger {%i} {#cw ",@itemcolor,"} {Color highlighting}")}
Note that %i is within a quoted portion (but will be expanded), and was being expanded in your old trigger command. This is because %i,%j,...%z are expanded early. In other words they are always expanded even when the command involved does not normally expand that parameter.
Reply with quote
glowack2
Newbie


Joined: 26 Oct 2002
Posts: 5
Location: USA

PostPosted: Mon Oct 06, 2003 7:24 pm   
 
Looks like that did the trick!!! Script appears to work correctly now, Thanks!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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