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
acaykath
Wanderer


Joined: 03 Aug 2005
Posts: 84

PostPosted: Sun Apr 06, 2008 6:57 pm   

%expand & %/$ Parameters
 
"title=%expand(%item(@TitleVar,$num))" treats "%item(@TitleVar,$num)" as a literal string rather than a function that is to be executed to get the parameter to expand. The same problem occurs when using local variables. It seems that it will only take @variables or else will treat as a literal string, which means it takes 4 lines of code bouncing between variables to execute what should only take one.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sun Apr 06, 2008 7:12 pm   
 
While there may be a problem with %expand, in most cases you don't need to use it. If we could see the whole of your code, we could suggest a better way.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
acaykath
Wanderer


Joined: 03 Aug 2005
Posts: 84

PostPosted: Sun Apr 06, 2008 8:22 pm   
 
Timed trigger *180
Code:
title=%item(@TitleVar,%random(1, %numitems(%expand(@TitleVar))))
title %expand(@title)

@title is a placeholder variable, useless except to get around the bug.
@titlevar is a string list of titles, some of which contain references to other variables, thus the need for expansion.

Assuming everything worked right, this could be written as a single line of nested function calls, but this was the only way I found to get the functionality I wanted (though I can break it up furthur into more easily readable lines but it is now more compact than it was when I posted.).
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Sun Apr 06, 2008 9:33 pm   
 
Code:
%stripq(%item(@TitleVar,%random(1, %numitems(%expand(@TitleVar)))) )

_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
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