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
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Mon Nov 10, 2008 4:35 am   

String triggers...How to pull the triggered string item to a variable?
 
So this is what I tried to do...

I tried setting up a string list... listing 15 different types of item loot.

But I couldn't figure out how to pull whichever item triggerd the stringlist.


So now I have 15 different triggers.

i.e.

Pattern: Chest
Trigger: #var glist %additem( "chest", @glist)




instead i want something like this


Pattern: ({%%dbkeys(@boxlist)})
Trigger : #var glist %additem( %1, @glist)


I tried various ways to pass the pattern variable to different variables, but no go. Any help would be greatly appreciated! :)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Nov 10, 2008 4:44 am   
 
#trigger "name of trigger goes here" {stuff before boxlist({@boxlist})stuff after boxlist} {code goes here} "class this trigger is in goes here" {trigger options go here}

From there, you use %1 and other code to assign it to a variable. Like, for instance, ThisBox = %1.
_________________
EDIT: I didn't like my old signature
Reply with quote
Tarken Aurelius
Apprentice


Joined: 23 Oct 2008
Posts: 120
Location: Cincinnati, Ohio

PostPosted: Mon Nov 10, 2008 4:45 am   
 
Try this:


Code:

#var glist {a|b|c|d|e|f|g}
#TRIGGER {({@glist})} {#var curloot %1}



You can use a variable in the pattern and it will match to that string list (assuming it is a string list). If you place parenthesis around it, then you can also use it as %1, %2 etc in the value to do whatever you want with it.
Reply with quote
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Mon Nov 10, 2008 5:18 am   
 
Great!

I can see where I went wrong before when I tried doing the () trick to pass the variable to %1.


({%%dbkeys({@boxlist})})

Works awesome :) !! You shoulda seen me trying to stick the () in random places... and trying to use && variable option.


Is there any particular reason why the bracket is needed around @boxlist(or @glist) to get the variable to pass through?


Thanks a ton, both of your examples were very helpful!
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Nov 10, 2008 10:11 pm   
 
The {} are needed to signify that the data contained within is a stringlist--a multiple-choice variable.

The parentheses are needed if you want to expose the result to any of the code this trigger is going to execute. This exposure takes the form of %1...%99, based on the position of each set of () or &varname item:

#trigger {(this) is a stringlist of &%dlistcount items} {}

%1 = "this"
%2 = some number (1, 2, 3, etc) that appeared in this spot
_________________
EDIT: I didn't like my old signature
Reply with quote
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Tue Nov 11, 2008 10:59 am   
 
Awesome.


Very helpful.


Thanks!
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