Capturing Two Lines of Text

All and any discussion and development of the Mudlet Mapper.
Post Reply
solfeggio
Posts: 4
Joined: Wed Apr 08, 2015 9:18 pm

Capturing Two Lines of Text

Post by solfeggio »

Hello,

I would like some advice on writing a trigger to capture and store two consecutive lines of text for my mapper script.

On any player movement, the MUD generates two consecutive lines with Room Description and Exits, such as:

A City Sidewalk
(Exits: n e w s)

How can I make a trigger that will react to the "Exits" line and also capture the previous line, which can be any string of characters? I know how to write the regex for the "Exits" line alone, but I am at a loss for how to write a two-line trigger that matches "Line 1: [Anything], Line 2: (Exits: ...)".

Any help greatly appreciated, as always!

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: Capturing Two Lines of Text

Post by Belgarath »

Code: [show] | [select all] lua
-- 0 (regex): .+
-- 1 (begin of line): (Exits:

local room_description = multimatches[1][1]
local exits = multimatches[2][1]
And you'll want to tick the 'multiline / AND Trigger' and set line delta to 1. Hope this helps. 8-)
Last edited by Belgarath on Thu Apr 16, 2015 7:49 am, edited 4 times in total.

solfeggio
Posts: 4
Joined: Wed Apr 08, 2015 9:18 pm

Re: Capturing Two Lines of Text

Post by solfeggio »

Thank you for having a look at this. I created the trigger you described above, and it does capture the room description and exits... but, it also captures every other line of text sent by the MUD. (I checked this by clicking the "highlight" checkbox and setting the foreground/background colors to something distinct.) Every line is matching the trigger.

I did verify that Multiline/ALL is selected, and line delta set to 1.

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: Capturing Two Lines of Text

Post by Belgarath »

I tested it myself and it only captured my room exits and the previous line. I'm not sure why it is matching every line for you.

Post Reply