Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Multiline trigger issues
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Keberus
(31 posts) Bio
|
Date
| Sun 03 Jan 2010 06:05 PM (UTC) Amended on Sun 03 Jan 2010 06:06 PM (UTC) by Keberus
|
Message
| Okay, I have multi-line prompt and I want to capture some info from each line, the prompt looks something like so:
Force 2000/2000 Align 530 Mail 0/9 Room#<109>
Hp:1000/1000 Move:1000/1000 Gold:9,744,232 <>
I am trying to pull Force stats, hp, and movement. I have written a few triggers to test this which work, separately. They look like so:
<triggers>
<trigger
enabled="y"
expand_variables="y"
match="^Force (\d+)\/(\d+)"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable("curr_force", "%1" )
SetVariable("max_force", "%2" )</send>
</trigger>
</triggers>
and:
<triggers>
<trigger
enabled="y"
lines_to_match="2"
match="^Hp\:(\d+)\/(\d+) Move\:(\d+)\/(\d+)"
name="hp"
regexp="y"
send_to="3"
sequence="100"
>
<send>Hit Points %1/%2 ...Move %3/%4</send>
</trigger>
</triggers>
They both work fine separately, but I can't seem to get them to combine right I've tried this:
<triggers>
<trigger
enabled="y"
lines_to_match="2"
match="^Force (\d+)\/(\d+)*Hp\:(\d+)\/(\d+) Move\:(\d+)\/(\d+)"
multi_line="y"
regexp="y"
send_to="3"
sequence="100"
>
<send>Fp %1/%2 Hit Points %3/%4 ...Move %5/%6</send>
</trigger>
</triggers>
I have also tried many versions of the above with different combos of * and \n...to no avail. If someone could show me what I'm doing wrong it would be much appreciated.
Thanks,
KeB | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sun 03 Jan 2010 07:41 PM (UTC) Amended on Sun 03 Jan 2010 07:42 PM (UTC) by Nick Gammon
|
Message
| I presume there is a typo in the last example, and that:
should read:
Otherwise it will certainly not behave as you expect, since I gather you are trying to skip various stuff you are not interested in.
Basically you need to turn on the "dot matches all" option, otherwise newlines are not caught in the .* sequence.
The version below works for me:
<triggers>
<trigger
enabled="y"
lines_to_match="2"
match="(?s)^Force (\d+)\/(\d+).*Hp\:(\d+)\/(\d+) Move\:(\d+)\/(\d+)"
multi_line="y"
regexp="y"
send_to="3"
sequence="100"
>
<send>Fp %1/%2 Hit Points %3/%4 ...Move %5/%6</send>
</trigger>
</triggers>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #2 on Sun 03 Jan 2010 07:45 PM (UTC) |
Message
| Right, the * symbol has different meanings depending on whether you have regular expressions enabled for the trigger. With it off, it will match a single word, but when regex is enabled, it's a flag that means "zero or more of the preceeding character". |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Keberus
(31 posts) Bio
|
Date
| Reply #3 on Sun 03 Jan 2010 08:43 PM (UTC) |
Message
| Sorry, it wasn't a typo. I didn't realize that I needed .* instead of just *. Thanks again for the help Nick. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
12,134 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top