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


Joined: 20 Oct 2006
Posts: 51

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


Joined: 20 Oct 2006
Posts: 51

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


Joined: 02 Feb 2003
Posts: 99
Location: Seattle, Wa

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


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

PostPosted: Fri Aug 26, 2011 2:25 am   
 
#IF (%match(%2, "sun")) {do stuff}
_________________
Discord: Shalimar#3679
Reply with quote
geniusclown
Magician


Joined: 23 Apr 2003
Posts: 358
Location: USA

PostPosted: 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
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