|
Erasmus Wanderer
Joined: 04 Aug 2004 Posts: 82 Location: Philadelphia
|
Posted: 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 |
|
|
|
Vorax Apprentice
Joined: 29 Jun 2001 Posts: 198 Location: USA
|
Posted: Fri Dec 24, 2004 4:04 am |
Try this, change your bold statement to:
#IF (%match("%1", "%d players")) {#STATE trgWhoList 0} |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: 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} |
|
|
|
|
Erasmus Wanderer
Joined: 04 Aug 2004 Posts: 82 Location: Philadelphia
|
Posted: 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 |
|
|
|
|
|