needing help on a trigger

Posted by KewlGuy on Sat 01 Jan 2005 04:10 PM — 11 posts, 34,763 views.

#0
heya all,
ive gone through like 90% of these forums and havn't come across anything that has helped me with one trigger i want to get working but ive also learned alot im basicly new to muchclient well that's enough bable bout this any how here is the problem i have

i want a line to show in status bar on this text:

hp: */* sp: */* mana: */* e: [*] pty: (*%)

NB * = numbers and letters also : character

the problem i believe i have is it doesn't like to pick up the
e: [*] pty: (*%)
the e: [*] is sposed to be [monster : status] or [none] whene in and out of battle
pty: (*%) is percent of faith my god has in me
ive tried with out monster status so i can get pty to work but it says it can't work cause it doesn't like \p or \P

and so this has stumped me like totally i think ive tried nearly all the techiques that are shown in these forums
so i thought id ask and see if anyone can enlighten me on my problem

thanks in advance
KewlGuy

Australia Forum Administrator #1
All this stuff can be made to work, there is practically nothing you can't do with triggers and regular expressions.

However to help you we need more information:



You have said it doesn't like \p - it is hard to know what you mean without seeing the trigger you are writing.
#2
okay here is an example of what i need it to work from

HP: 762/740 SP: 152/315 MANA: 58/1315 E: [none] PTY: (71%)

now for what i have so far that is working

<triggers>
<trigger
enabled="y"
ignore_case="y"
lines_to_match="2"
match="HP\:\s+\d+\/\d+\s+\SP\:\s+\d+\/\d+\s+\MANA\:\s+\d+\/\d+"
regexp="y"
send_to="3"
sequence="100"
>
<send>%0</send>
</trigger>
</triggers>


basicly what im trying to do is put that line on the status bar cause my battles in the game get really spammy ant it's very hard to know what my stats are for every round unless it's somewhere like the status bar
Australia Forum Administrator #3
OK, that worked, so what is the problem exactly?


HP: 762/740 SP: 152/315 MANA: 58/1315 E: [none] PTY: (71%)
TRACE: Matched trigger "HP\:\s+\d+\/\d+\s+\SP\:\s+\d+\/\d+\s+\MANA\:\s+\d+\/\d+"


I turned trace mode on to confirm it matched. And it copied the status line to the status bar.
Amended on Sat 01 Jan 2005 07:13 PM by Nick Gammon
#4
the problem is i can't find a way to get the mob status and pty into the status bar what i have there and working so far is just hp sp and mana if you know what i mean

what i want is the whole line that shows to goto the status bar

ive tried lots of different ways but can't seem to get it to work i can however get it to pick up some of the things and others it tells me whene i goto click okay that it doesn't parse it correctly or there is an error but i can't seem to see the error myself
#5
what also make it alot harder for me is that the E: [none] changes in battle to a format like this

E: [Owen the : bleeding]
USA #6
Just tack on a .* at the end of that.

Actually, add '^' to the beginning, and .*$ to the end (^ and $ will ensure you capture the entire line)

^HP\:\s+\d+\/\d+\s+\SP\:\s+\d+\/\d+\s+\MANA\:\s+\d+\/\d+.*$
#7
ahhhh that worked thanks i must of had the syntax for tacking the * on the end wrong thanks guys for the help ;)
USA #8
Or you could get more fancy and make sure it has the E: and the PTY:

Like this:
^HP\:\s+\d+\/\d+\s+\SP\:\s+\d+\/\d+\s+\MANA\:\s+\d+\/\d+ E\:\[.*\] PTY\: \(\d{1,3}\%\)$
If you have trailing spaces, you'll need to allow for those:
^HP\:\s+\d+\/\d+\s+\SP\:\s+\d+\/\d+\s+\MANA\:\s+\d+\/\d+ E\:\[.*\] PTY\: \(\d{1,3}\%\).*$
Australia Forum Administrator #9
OK, I got it to match. I reworked your trigger a bit, to make it a bit easier to read. Fortunately I was just doing a write-up on regular expressions yesterday. :)


<triggers>
  <trigger
   enabled="y"
   ignore_case="y"
   lines_to_match="2"
   match=
"(?x) HP: (\s+ \d+ / \d+ \s+) SP: (?1) MANA: (?1) E: \s+ \[ .* \] \s+ PTY: \s+ \( \d+ % \)"
   regexp="y"
   send_to="3"
   sequence="100"
  >
  <send>%0</send>
  </trigger>
</triggers>


What you probably did wrong, although it is hard to say without seeeing the one that didn't work, is that with brackets you need to "escape" them by putting a backslash in front of them.

Also for SP you had it as \SP which is wrong, because \S means "match on not a space", which probably worked for S (which is not a space) but is confusing.

In the trigger above I put in (?x) so I could put in spaces to make it clearer. I also used the (?1) idea so that the matching on (space)(number)/(number)(space) didn't have to be written three times over.

Amended on Sat 01 Jan 2005 07:27 PM by Nick Gammon
Australia Forum Administrator #10
Quote:

what also make it alot harder for me is that the E: [none] changes in battle to a format like this

E: [Owen the : bleeding]


Using \[.*\] will match that easily enough.