|
JWhitney Wanderer
Joined: 20 Oct 2006 Posts: 51
|
Posted: Thu Aug 25, 2011 11:53 pm
Matching text in a string |
Hello,
This is probably a simpler issue than I am making it, but I can't seem to find the answer. I am looking for a way to search a wildcard string for a specific word, and #IF it contains that, execute some commands.
Output from the game:
Code: |
Conjunction 382 seconds from now: Sun, Mercury, Venus, |
Trigger Pattern:
Code: |
^Conjunction (%d) seconds from now:(%*) |
Trigger Value:
Code: |
#IF (%2 = " Sun,") {#VAR druid_conj {%1}} |
Basically, what I'm looking for is a way to search the %2 string for "Sun", and then execute commands, then do the same for "Mercury", "Venus", etc. I looked in to %match and even %regex, but can't seem to find a way to make this work. Am I missing something?
Thank you for your time.[/code] |
|
|
|
JWhitney Wanderer
Joined: 20 Oct 2006 Posts: 51
|
Posted: Fri Aug 26, 2011 12:27 am |
I found a roundabout way to doing this, here's what I did:
#IF (%pos("Sun",%2) > 0) {do commands}
If there's a better way, great, but is functional. Thanks for reading anyway! |
|
|
|
Mixsel Wanderer
Joined: 02 Feb 2003 Posts: 99 Location: Seattle, Wa
|
Posted: Fri Aug 26, 2011 12:38 am |
dunno if %ismember would work?
Code: |
#IF (%ismember("sun",@planets) {do Stuff} {or not do stuff} |
[/url] |
|
_________________ Spin |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Fri Aug 26, 2011 2:25 am |
#IF (%match(%2, "sun")) {do stuff}
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
geniusclown Magician
Joined: 23 Apr 2003 Posts: 358 Location: USA
|
Posted: Fri Aug 26, 2011 3:57 am |
You want to do stuff for anything in %2? How about:
Code: |
#FORALL (%replace(%2,", ","|")) {#SWITCH (%i)
("Sun") {do stuff if sun is in conjunction}
("Mercury") {do stuff if mercury is in conjunction}
("Etc") {do stuff if Etc is in conjunction}
(1) {#ECHO In conjunction with %i! I don't know what to do!}
} |
(EDIT: fixed a typo) |
|
_________________ .geniusclown |
|
|
|
|
|
|
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
|
|