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
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Mon May 26, 2003 12:58 am   

Stupid Pattern Matching Question
 
Okay, here is what I am looking at. When getting the score of my character it lists several extra things like race, level, etc. I am trying to capture those but seem to be having trouble matching the pattern. One line looks like this:

Level : 8 Ranked : Harmless

i tried #TRIG {^(%s)Level :(%n)(%s)Ranked(%s): (%w)} {level=%2;rank=%5}
and while it i matching on my test match, when I actually bring it up through the mud, nothing gets put in my vars.

Any ideas?

By the way, there is a space before Level
Reply with quote
Darkmere
Novice


Joined: 23 May 2003
Posts: 31

PostPosted: Mon May 26, 2003 1:22 am   
 
#TRIGGER {^ Level~: (%d) Ranked ~: (%w)} {#VAR level {%1};#VAR rank {%2}}

If the phrase after 'Ranked :' is more then one word at times, change the (%w) to (*)

-Darkmere-
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Mon May 26, 2003 1:51 am   
 
Still not getting it recorded. The spacing is lined up with other lines, should I use the number of spaces between the level number and Ranked or is your way better?
Reply with quote
Darkmere
Novice


Joined: 23 May 2003
Posts: 31

PostPosted: Mon May 26, 2003 2:01 am   
 
Is there more then one space inbetween any word/number/symbol on your mud? If so, you have to modify my code a bit. Zmud automatically sets more the one regular space in your command, to just 1 (kinda annoying). I am not familiar with (%s) as you had in your first code.

If there is more then one space, try this code perhaps:

#TRIGGER {^(*)Level(*)~:(*)(%d)(*)Ranked(*)~:(*)(%w)$} {#VAR level {%1};#VAR rank {%2}}

I just now see though, that I left out a space in my original post - try this first, if it doesnt work, try the above:

#TRIGGER {^ Level ~: (%d) Ranked ~: (%w)} {#VAR level {%1};#VAR rank {%2}}

^This should work as I didn't see the space between level and :

-Darkmere-
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Mon May 26, 2003 3:12 am   
 
Okay...as a whole, neither worked. But the #TRIGGER {^ Level ~: (%d) part by itself did. There are 9 spaces between the level number and the word Ranked. Should I put those nine space after the (%d) or add an extra space?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon May 26, 2003 3:15 am   
 
Most of the time you don't need to, but every once in a while you might come across a situation where you need to explicitly capture the multiple spaces instead of letting them get included in one of the other variables (in those situations, ZMud tends to reduce the extra spaces down to just one space).

%s - matches one continuous sequence of whitespace (spaces, tabs, other non-return/linefeed unprintable characters)

(%s) - same as above, except ZMud assigns that match to one of the %1...%99 system variables.
li'l shmoe of Dragon's Gate MUD
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Mon May 26, 2003 3:22 am   
 
This is how the part of my score shows up:

Race : Sidhe Gender : Male
Level : 8 Ranked : Harmless
Health: 54/54 Endurance: 170/170
Mana : 65/65 Willpower: 225/225


Now...the left ones start at position 2 of the line(1 space in), the right ones all start in the 20th position. If this helps any..yay.

Matt: There is a difference between %s and (%s)? If so, should using %s between (%d) and Ranked in the trigger work?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon May 26, 2003 6:01 am   
 
Trigger set for above score snippet:
#TR {^ Race%s: (%w)%sGender%s: (%w)} {#VAR race %1;#VAR gender %2}
#TR {^ Level : (%d)%sRanked%s: (%w)} {#VAR level %1;#VAR ranked %2}
#TR {^ Health: (%n)/(%d)%sEndurance: (%n)/(%d)} {#VAR health %1;#VAR maxhealth %2;#VAR endurance %3;#VAR maxendurance %4}
#TR {^ Mana%s: (%n)/(%d)%sWillpower: (%n)/(%d)} {#VAR mana %1;#VAR maxmana %2;#VAR willpower %3;#VAR maxwillpower %4}

If you know the exact number of spaces, you can use them. If not, you need to use %s to account for them. Therefore, you could use two spaces after Race if you wanted, instead of %s. %s does require at least one space (or TAB/other whitespace) to match.

The difference between %s and (%s) is that %s doesn't get a number, but (%s) does.
#TR {(%w)(%s)(%d)} {#SAY %1 is all letters, %2 is all spaces, and %3 is all digits}
#TR {(%w)%s(%d)} {#SAY %1 is all letters, then there's some spaces, but %2 is all digits.}

LightBulb
Advanced Member
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Mon May 26, 2003 6:43 am   
 
Thanks..that did the trick
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