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: Wed May 27, 2009 4:58 pm   

Stringlist comparison inside a trigger
 
Hey, having a bit of trouble here.

Pattern: XXXX
Code:

#if (@obs_t = {@lor_l}) {#add lor_pool 1}
#if (@obs_t = {@off_l}) {#add off_pool 1}
#if (@obs_t = {@def_l}) {#add def_pool 1}
#if (@obs_t = {@mag_l}) {#add mag_pool 1}
#if (@obs_t = {@sur_l}) {#add sur_pool 1}




This doesn't work :( How can I fix it? All the lists on the right side of the equation are multiple stringlist variables. The variable on the left side is a single variable. I'm basically trying to keep track of which observations triggers. Also, some @OBS_T are in two or three lists.

Any ideas or anything to point me in the right direction would be awesome.

Thanks!
Reply with quote
shalimar
GURU


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

PostPosted: Wed May 27, 2009 5:02 pm   
 
%ismember(@singlevar, @listvar)
_________________
Discord: Shalimarwildcat
Reply with quote
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Wed May 27, 2009 5:23 pm   
 
Works awesome :) Thanks!

Code:

#if (%ismember(@obs_t, @lor_l)) {#add lor_pool 1;#echo Adding 1 to the Lore pool. @lor_pool total.}
#if (%ismember(@obs_t, @off_l)) {#add off_pool 1;#echo Adding 1 to the Offense pool. @off_pool total.}
#if (%ismember(@obs_t, @def_l)) {#add def_pool 1;#echo Adding 1 to the Defense pool. @def_pool total.}
#if (%ismember(@obs_t, @mag_l)) {#add mag_pool 1;#echo Adding 1 to the Magic pool. @mag_pool total.}
#if (%ismember(@obs_t, @sur_l)) {#add sur_pool 1;#echo Adding 1 to the Survival pool. @sur_pool total.}
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed May 27, 2009 5:24 pm   
 
You're attempting to do a pattern comparison, which uses the =~ operator, not =. %ismember is the more orthodox way of doing this kind of comparison.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Wed May 27, 2009 5:27 pm   
 
Quote:
which uses the =~ operator, not =.




Whats that =~?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed May 27, 2009 5:47 pm   
 
a =~ b means "a matches pattern b", as opposed to a = b which means "a equals b". {@stringlist} is a pattern that'll match any item in the list, so @obs_t =~ {@lor_l} would mean "@obs_t matches any item in @lor_l".
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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