|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Mon Nov 17, 2008 7:14 pm
Pattern Help |
Ok, I have the following script:
Code: |
#CLASS {Automatic Practice|AutoGetAll}
#TRIGGER {(*)%s(%d)%s(%d)%s(%d)} {
#CLASS {Automatic Practice|Vars}
#ADDKEY ToPracDB %1 %concat( %2, "|", %3, "|", %4)
#CLASS 0
}
#CLASS 0 |
But when it captures multi-word spell names, it doesn't work right and I get THIS (I manually edited this to make it easier to read for viewing purposes...):
Code: |
#CLASS {Automatic Practice|Vars}
#VAR ToPracDB {
complete=healing
cure=light
group=massive
heal=over
mana=133|90|90
power=heal
refresh=10|90|83
restoration=48|90|83
massive=heal
fast=healing
meditation=33|90|14
}
#CLASS 0 |
Here is the input:
Code: |
Skill Level Maxskill Current
complete healing 103 90 83
cure blindness 13 90 83
cure critical wounds 0 90 83
cure disease 8 90 83
cure light wounds 0 90 83
group heal 58 90 0
group restoration 93 90 0
heal 2 90 83
mana 133 90 90
power heal 28 90 83
group massive heal 158 90 0
heal over time 153 90 77
refresh 10 90 83
restoration 48 90 83
massive heal 133 90 0
fast healing 28 90 14
meditation 33 90 14
8226hp 6741m 1606mv> |
How do I fix the pattern, it looks right to me... I mean this should be pretty straightforward. |
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
Rappy Wanderer
Joined: 15 Jul 2005 Posts: 96
|
Posted: Mon Nov 17, 2008 9:08 pm |
The %s is picking up the space between the first and second words, best option is to change it to a regex trigger and use...
Code: |
#REGEX {([\w ]+)\s(\d)\s(\d)\s(\d)} |
And you should think about somehow turning it on and off so this 'loose' trigger doesn't catch other randomness from the MUD.
Look into #T+ and create an alias (possibly the same command you use to check that listing... IE #ALIAS skilllist {#T+ skillgroup;~skilllist} and then add a #T- triggered off your prompt %dhp %dm %dmv>
-Rappy |
|
_________________ Windows 11 Pro,
cMUD 3.34 |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Mon Nov 17, 2008 9:25 pm |
%s should only pick up a space right BEFORE a number though. So something is broken as can be there.
And yes Rappy, its already T+/-'ed ;)
Regardless, I'll use the REGEX, but dammit, the other SHOULD work. The space between words should not make the pattern match since the net param isn't a NUMBER ;) How is a word getting picked up as %2 when it is a (%d) in the pattern? Something is SERIOUSLY broken there. Oh well, meh. |
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Mon Nov 17, 2008 9:28 pm |
Rappy: that shouldn't cause a problem, as the (*)%s(%d) matches anything FOLLOWED by a space or more FOLLOWED by a digit. Therefore, it should match asfks seied skiei 4 without a flaw.
This can be tested by stripping it down to just #SAY First param is %1 and second param is %2.
Test that against the output and see if it matches correctly. It should.
Charneus |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Mon Nov 17, 2008 9:39 pm |
I found the problem. And I feel dumb now since this is a problem I've encountered sooo many times and I just forgot it when I wrote the code.
I need to put double quotes around my %1 to properly read the space into the var.
Code: |
#CLASS {Automatic Practice|AutoGetAll}
#TRIGGER {(*)%s(%d)%s(%d)%s(%d)} {
#CLASS {Automatic Practice|Vars}
#ADDKEY ToPracDB "%1" %concat( %2, "|", %3, "|", %4)
#CLASS 0
}
#CLASS 0 |
Sorry for wasting your time guys *feels stupid* |
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Mon Nov 17, 2008 9:54 pm |
Heh, I was about to suggest that or {}'s. Basically when there's a possibility of the key being more than one word you should use it.
Though, perhaps another way would be %-1 and then you wouldn't need to use quotes nor {}'s. |
|
_________________ The Proud new owner of CMud.
--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
-------------------------------- |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Mon Nov 17, 2008 10:13 pm |
Can't use %-1 since there is a %2 to use ;)
But yes, I got it :p |
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Nov 17, 2008 10:22 pm |
If you replace the * with a narrower pattern, it will work properly. [%w%s] will work, but you'll probably have to %trim() the result.
You could even attempt to try using 2 consecutive plain-text spaces in the pattern to get rid of the trimming need, but ZMud might strip that out automatically or might not match it. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Mon Nov 17, 2008 11:26 pm |
Right Matt, except I want it to work on multiple words as well as singles.
|
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
|
|