|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4686 Location: Pensacola, FL, USA
|
Posted: Sat Nov 25, 2006 11:52 pm
[1.16] Forall ignores aliases |
#ALIAS reset {#VAR dostuff {}}
#VAR dostuff {get @thrown|sheath @thrown|reset}
#FORALL @dostuff {%i}
I have a trigger set to do the forall statement that fires frequently.
But it should only do stuff once with that value for @dostuff.
That is not the case... the value 'reset' is getting sent directly to the mud and not getting expanded as an alias. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Nov 27, 2006 6:31 am |
You need to use #EXEC if you want to execute the results. Just putting %i is ambiguous since it's not clear what you want to do with the result. Use #EXEC to execute it, #SEND to send it to the mud, #ECHO to display it, etc.
|
|
|
|
The Raven Magician
Joined: 13 Oct 2000 Posts: 463
|
Posted: Mon Nov 27, 2006 10:26 pm |
I think this is a bug Zugg. Let me explain why:
#ALIAS Foo {bar}
If you use this alias, then bar will be processed normally... as in, it will be checked to see if it is an alias, or sent directly to the MUD otherwise. The problem is that if you put it inside ANOTHER command, this default behavior breaks. For example:
#ALIAS Foo {#FORALL @dostuff {%i}}
The nesting level should not affect how CMUD interperets commands. If #FORALL interperets its command differently than #ALIAS, that is either a bug or it needs to be documented. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Nov 27, 2006 10:51 pm |
No, this isn't a bug...it's the difference between how zMUD did parsing and how CMUD does parsing. In zMUD, things like %i and %1..%99 were done as string replacements *before* parsing. That's why your alias worked in zMUD. In CMUD, this "pre-replacement" is not done. %i is handled just like a variable reference. So it's the same as doing:
#FORALL @dostuff {@varname}
Now, just putting a variable name or function call just causes the result to be sent to the MUD. It does not cause the result to be executed. To mimic the old zMUD way of doing it, you need to specifically use #EXEC.
zMUD was doing an #EXEC, but you just didn't see it because of the pre-replacement of the string data.
It's not a difference between #FORALL or anything to do with the nesting level. It's happening because %i is a *variable reference*. So, your equivalent test alias should be
#ALIAS Foo {@bar}
and you'll find that this does *not* perform the alias check either. CMUD is making you be more explicit about what you are doing so that your scripts are more readable. By putting in an #EXEC call then it's more obvious that %i contains commands or aliases that you want to execute instead of just plain text to send to the MUD. |
|
|
|
The Raven Magician
Joined: 13 Oct 2000 Posts: 463
|
Posted: Tue Nov 28, 2006 12:47 am |
Ahh, I gotit now Zugg, thanks.
|
|
|
|
|
|