|
Haldrik Wanderer
Joined: 03 Sep 2007 Posts: 88
|
Posted: 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! |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Wed May 27, 2009 5:02 pm |
%ismember(@singlevar, @listvar)
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Haldrik Wanderer
Joined: 03 Sep 2007 Posts: 88
|
Posted: 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.}
|
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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.
|
|
|
|
Haldrik Wanderer
Joined: 03 Sep 2007 Posts: 88
|
Posted: Wed May 27, 2009 5:27 pm |
Quote: |
which uses the =~ operator, not =. |
Whats that =~? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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".
|
|
|
|
|
|