A trigger that is split over multiple lines?

Post Reply
Jarrin
Posts: 20
Joined: Sat Nov 21, 2009 10:14 pm

A trigger that is split over multiple lines?

Post by Jarrin »

Ok, so I'm trying to create a trigger that will capture the general area of my farsee target.

my regex trigger looks like this:

Code: Select all

^Though too far away to accurately perceive details, you see that (.*) is (.*).
The problem I'm having is that when my target is not in the same area as I am the output from the mud is always broken up into multiple lines and I never know exactly where the boundary will be between the first and second line.

Mud Output might be:
Though too far away to accurately perceive details, you see that Person is in
Shallam.
Could also look like:
Though too far away to accurately perceive details, you see that Person is in the
Lost City of Kasmarkin.
What am I missing?

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: A trigger that is split over multiple lines?

Post by Heiko »

1. The simplest solution would be to set your screen width to 0, thus letting the MUD send all responses to your commands as single lines of unlimited length. Mudlet will wrap the lines for you according to your line wrap settings. This makes scripting *much* easier.

2. If you MUD doesnt support this feature (most big MUDs do though) you have to write a proper multiline trigger using the multistate machine -> pattern list.
Triggers are run on the entire line as sent by the MUD. You can use our multi condition AND trigger feature to accomplish what you want to do. The trigger will fire when all conditions are true i. e. when all patterns on the pattern list of the trigger have been found within the delta of lines defined in the trigger AND condition (=line margin).
a) In your example the pattern can occur in 1 or 2 lines -> set line delta to 2.
b) first pattern type regex:Though too far away to accurately perceive details, you see that (\w+) is in
second pattern type regex:^(.*)\.$
script:

Code: Select all

echo( "GOT: person=" .. multimatches[1][2] .. " city=" .. multimatches[2][2] )

Post Reply