|
Eyeless Wanderer
Joined: 02 Dec 2001 Posts: 80 Location: Canada
|
Posted: 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) |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Mon Mar 01, 2004 12:51 pm |
The problem wasn't with %-1 it is with the #VAR command.
#ALIAS fo {#VAR forage {%-1}} |
|
|
|
Eyeless Wanderer
Joined: 02 Dec 2001 Posts: 80 Location: Canada
|
Posted: 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... |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: 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 |
|
|
|
Pega Magician
Joined: 08 Jan 2001 Posts: 341 Location: Singapore
|
Posted: 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. |
|
|
|
|
|