Multiple line triggers that can slightly vary

Posted by Tboydston on Fri 10 Apr 2009 11:28 PM — 4 posts, 17,754 views.

#0
I am trying to make a trigger that matches this:
Cutting open the corpse of a Mhun guard, you begin to rummage around the innards
to find an appropriate place to remove the kidneys. Your sharp eye immediately
sees a spot and you excise the lovely organ.

The problem is that the target "Mhun guard" changes and so does the formatting of the three lines. Sometimes the "to find" from the second line is on the first line, and sometimes "rummage" is on the second line. If it all stays in one place, I know how to make this trigger, but I can't make it work with shifting text.

I know I could make quite a few single line triggers that just try to match the variation of the middle line (which is the only line I really need), but I'd rather find a way just to make one trigger that looks for all of those words and doesn't care of the line order.

Here's the XML for me catching one line:
<trigger

enabled="y"
match="^innards to find an appropriate place to remove the (\w*)\. Your sharp eye $"
regexp="y"
script="gotOrgan"

send_to="12"

sequence="100">
</trigger>
Australia Forum Administrator #1
See my suggestion in this thread:

http://www.gammon.com.au/forum/bbshowpost.php?id=8845

Basically you could make a regular expression trigger with \s in the place of every space, as \s also matches a newline.
Netherlands #2
Or, since I am pretty sure you are playing Aetolia... Try the mud command CONFIG WRAPWIDTH 0, and configure MUSHclient to do the wrapping in the Output screen of your Configuration.

This way, the mud won't do any wrapping of its own, making it far easier to trigger things.
USA #3
If there's no simpler recourse, one technique I've had some success with is to make a "begin" trigger that matches enough of the first line to be sure you have the right one, and an "end" trigger that matches on the prompt (or some other distinctive ending line). A third trigger, ^.*$, would catch everything in between, but be higher in Sequence so it doesn't capture the ending trigger line before it gets shut off.

In the catch-all trigger, you'd append each line to a variable. In the end trigger, you could pass it through gsub or a PCRE pattern, or do whatever else you need to do with it.