Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Erasmus
Wanderer


Joined: 04 Aug 2004
Posts: 82
Location: Philadelphia

PostPosted: Thu Dec 23, 2004 8:45 pm   

Pattern Matching in an IF statement
 
I'm trying to write a trigger that captures the who list for a mud and puts it into a string list.

The who list looks something like:
>who

person 1
person 2
person 3

3 players

This is the code I have so far:
#TRIGGER "trgWhoList" {>who$} {#VAR WhoList ""}
#COND "trgWhoList" {(*)} {#ADDITEM WhoList "%1";#IF {~"%d players" = %1} {#STATE trgWhoList 0}} "" {looplines|param=99}

Everything works fine up until the point where I try to reset the trigger back to state 0 (in bold above). I can't seem to find the right pattern that will match the line "3 players". What am I doing wrong?
_________________
Erasmus
Reply with quote
Vorax
Apprentice


Joined: 29 Jun 2001
Posts: 198
Location: USA

PostPosted: Fri Dec 24, 2004 4:04 am   
 
Try this, change your bold statement to:
#IF (%match("%1", "%d players")) {#STATE trgWhoList 0}
_________________
Implementor at House of Ghouls
Telnet to House of Ghouls
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Mon Jan 03, 2005 3:40 pm   
 
You might want to do your check for the last line before you add a name to the WhoList variable. Also, I think that the syntax you were trying to use should look something like this:

Code:
#IF ("%1" =~ "%d players") {#STATE trgWhoList 0}
Reply with quote
Erasmus
Wanderer


Joined: 04 Aug 2004
Posts: 82
Location: Philadelphia

PostPosted: Wed Jan 05, 2005 7:40 pm   
 
I am just creating this to display in the status window so I'd rather pick up the total anyway.
_________________
Erasmus
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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