|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: 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 |
|
|
|
Darkmere Novice
Joined: 23 May 2003 Posts: 31
|
Posted: 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- |
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: 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?
|
|
|
|
Darkmere Novice
Joined: 23 May 2003 Posts: 31
|
Posted: 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- |
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: 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?
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: 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? |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: 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 |
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: Mon May 26, 2003 6:43 am |
Thanks..that did the trick
|
|
|
|
|
|