|
sdp0et Newbie
Joined: 20 Jan 2011 Posts: 2
|
Posted: Thu Jan 20, 2011 3:41 am
Variables inside trigger definition not expanding. |
I am trying again to make the change from zmud to cmud. I am currently using 2.37 since that, the most recent version my license covers.
I am having trouble with a script and have narrowed the issue down to the creation a trigger. To duplicate it as simply as possible, I created an alias that does the following:
Code: |
#FORALL "sword|ring|shield" {#temp %i {%i} {#SAY TRIGGERED ON %i}}
|
When this is executed, it creates three temp triggers with IDs of "sword", "ring", and "shield" as expected but each trigger pattern is "%i" rather than being the appropriate String. The action performed by each new triggers are correct. The xml of one is :
Code: |
<trigger name="ring" priority="31880" id="3188">
<pattern>%i</pattern>
<value>#SAY FOUND ring</value>
</trigger>
|
I've searched the forums and the web and found issues that seem similar but are not quite the same. I'd appreciate any help or suggestions. |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Thu Jan 20, 2011 4:26 am |
Change it to:
Code: |
#EXEC %concat("#temp ",%i," {",%i,"} {#SAY TRIGGERED ON ",%i,"}}") |
|
|
|
|
sdp0et Newbie
Joined: 20 Jan 2011 Posts: 2
|
Posted: Thu Jan 20, 2011 4:53 am |
Thanks for the reply. While that does work, it is not a desirable solution. Working that back into the original script is pretty ugly. Is there not a way t o this without manually concatenating and execing the statement? Similar things worked in zmud. Is there a reason it doesn't for cmud? Is there replacement functionality for it in cmud?
|
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Thu Jan 20, 2011 8:06 am |
As far as I know (and I've been trying to test this all night with different forms...) there isn't any other way. Don't know why this changed, and I can't think of any replacement functionality, but I'll continue looking.
|
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Thu Jan 20, 2011 1:33 pm |
#TEMP is extremely inefficient, and probably should be avoided if you can. Is there a reason you think you need #TEMP instead of enabling and disabling a permanent trigger? In fact, for this purpose, by far the most effficient method would be to put all three triggers into a new class and enable and disable the entire class. Creating and destroying triggers takes a lot of overhead, while #T+ and #T- is extremely efficient, both in computation and in the appearance of your code.
|
|
|
|
|
|