Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Eugenides
Newbie


Joined: 19 Apr 2010
Posts: 2

PostPosted: 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?
Reply with quote
Myrkul
Wanderer


Joined: 21 Aug 2008
Posts: 85

PostPosted: 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
Reply with quote
Eugenides
Newbie


Joined: 19 Apr 2010
Posts: 2

PostPosted: 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?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: 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
Reply with quote
Myrkul
Wanderer


Joined: 21 Aug 2008
Posts: 85

PostPosted: 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
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: 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?
Reply with quote
Myrkul
Wanderer


Joined: 21 Aug 2008
Posts: 85

PostPosted: 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
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: 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
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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