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


Joined: 02 Dec 2001
Posts: 80
Location: Canada

PostPosted: Mon Mar 01, 2004 12:18 pm   

%-1
 
Not sure what it quite means, therefore it gives me trouble but:

#ALIAS fo {#VAR forage %-1} ///does not work
#ALIAS gp {get %-1 from my backpack} /// does work

I know if I wanted one word objects that I could just use %1, but quite often I need 2 or 3 word objects, anywhere I can read more documentation on the %-1? (limited information in #ALIAS)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Mar 01, 2004 12:51 pm   
 
The problem wasn't with %-1 it is with the #VAR command.

#ALIAS fo {#VAR forage {%-1}}
Reply with quote
Eyeless
Wanderer


Joined: 02 Dec 2001
Posts: 80
Location: Canada

PostPosted: Mon Mar 01, 2004 1:40 pm   
 
Thanks... Now I'd like to understand actually whats occuring here, but I dont expect you to explain it... However, pointing me in the general direction of where to look would be nice

Currently searching the archives...
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Mon Mar 01, 2004 4:34 pm   
 
#ALIAS fo {#VAR forage %-1} ///does not work

FO dead rats
your alias will expand to
#VAR forage dead rats
Syntax: #VA [variable] [value] [defaultval] [classname]
and the first word will get stored as the value and the second word will be stored as the default value

#ALIAS fo {#VAR forage {%-1}} ///does not work
FO dead rats
will expand to
#VAR forage {dead rats}
storing both words in the variable without a default value


#ALIAS gp {get %-1 from my backpack} /// does work
works because
GP big book
expands to
get big book from my backpack
Reply with quote
Pega
Magician


Joined: 08 Jan 2001
Posts: 341
Location: Singapore

PostPosted: Mon Mar 01, 2004 6:22 pm   
 
The problem here does not lie with the #VAR command alone, it is in the way a zMUD script is processed. The lesson here is that %-1, %0, %1, %2, etc. expand before everything else in any zMUD script.


Let us assume that in your command parser you enter: fo mandrake roots
Code:
#ALIAS fo {#VAR forage %-1}
in the process of parsing the alias, it becomes:
Code:
#ALIAS fo {#VAR <u>forage mandrake roots</u>}
the #VAR command sees 'forage mandrake roots', as its parameters.


On the other hand, if you were to specify the contents of another variable as the #VAR parameter, for example:
Code:
#VAR <u>forage @herb</u>
now the #VAR command will receive, 'forage @herb' and expand it in its own time.
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