|
Eugenides Newbie
Joined: 19 Apr 2010 Posts: 2
|
Posted: Mon Mar 28, 2011 1:23 am
Trouble passing a string list to an event as multipule params |
hey I'm haveing a bit of a problem with this.
<trigger name="basherAfflictionTracker" priority="260" id="26">
<pattern>^You are afflicted with (%x).$</pattern>
<value>$afflictionNumber = %find(%1,affliction);
#raiseevent basherCureEvent %expandlist(%dbvalues($afflictionNumber)," ");
</value>
</trigger>
is the code, but I can't refer to each part in the stringlist as a different param.
any Ideas? |
|
|
|
Myrkul Wanderer
Joined: 21 Aug 2008 Posts: 85
|
Posted: Mon Mar 28, 2011 3:53 am |
[edit][/edit]
|
|
Last edited by Myrkul on Thu Apr 14, 2011 10:54 pm; edited 1 time in total |
|
|
|
Eugenides Newbie
Joined: 19 Apr 2010 Posts: 2
|
Posted: Mon Mar 28, 2011 7:24 am |
I may have phrased that poorly. My code for the trigger I'm having problems with is.
<trigger name="basherAfflictionTracker" priority="260" id="26">
<pattern>^You are afflicted with (%x).$</pattern>
<value>$afflictionNumber = %find(%1,affliction);
#raiseevent basherCureEvent %expandlist(%dbvalues($afflictionNumber), " ");
</value>
</trigger>
the code for the event that is raised is
#echo %1
thats just to test whats being passed.
so when I get the line from aetolia "You have been afflicted with sunlight_allergy."
%find returns the record number for sunlight allergy.
%dbvalues gets the info for sunlight_allergy which is 34cu|sunlight_allergy|eat ginseng|herb|3 0
which is then striped of the | and sent to my event.
so when tested
34cu sunlight_allergy eat ginseng herb 3 0
is echoed to the screen.
is there away to be able to refer to each of those words as a seperate param, because currently its still doing the whole thing as one param.
edit or a better way of going about this entirely? |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Mon Mar 28, 2011 11:28 am |
try setting the list into a new $localVar and pass t hat instead of function results?
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Myrkul Wanderer
Joined: 21 Aug 2008 Posts: 85
|
Posted: Wed Mar 30, 2011 3:26 am |
[edit][/edit]
|
|
Last edited by Myrkul on Thu Apr 14, 2011 10:54 pm; edited 1 time in total |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Mar 30, 2011 1:28 pm |
No, that's not strange at all. The same thing is true when you use a variable or function call as the argument of an alias or trigger, too. This is normal Cmud action.
My first suggestion would be to simply pass the stringlist itself as the argument, and expand it within the event.
My alternate suggestion would be to use
Code: |
#exec {#raiseevent basherCureEvent %expandlist(%dbvalues($afflictionNumber), " ")}
|
I believe that would expand the string before executing the raiseevent. However, I recommend against this unless it is absolutely necessary. #EXEC commands are not compiled until executed. This will slow your code down. It also can contribute to other difficulties. #EXEC should be used sparingly, and only when necessary. Is there a good reason not to pass the stringlist to the event? |
|
|
|
Myrkul Wanderer
Joined: 21 Aug 2008 Posts: 85
|
Posted: Wed Mar 30, 2011 1:39 pm |
[edit][/edit]
|
|
Last edited by Myrkul on Thu Apr 14, 2011 10:53 pm; edited 1 time in total |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Mar 30, 2011 2:03 pm |
It is somewhat counterintuitive, but it is also extremely useful. It means that you can do things like:
Code: |
#alias color {#mxp %concat("<c ",%2,">",%1,"</c>")} |
and have it work on both:
Code: |
color "This is in red" red
color $text $color
|
|
|
|
|
|
|