Hello,
I've read a bit about multiline triggers on here and understand (And have experienced) the pain they can be. I am trying to capture "items" to then be processed via a script. THe description of these items can be variable length. The other challenge is the MUD supplies the line breaks, there is no option to not break or a setting or anything.
As an example, here is some output:
[*][SAFE]<3010hp 3286sp 2356st>
look key
You focus your powers of observation on a porcelain key:
Item 'a porcelain key' is type key, alignment 0, made of stone (in (new) condition),
has keywords 'porcelain key'.
This item weighs 0 stones and 4 pebbles, and is valued at 10 gold. {Cat. 0}
This level 0 item has the attributes: no-auction
This key may be used 1 more time.
*This item may be repaired 8 times.
*A porcelain key will last approximately 850 more Alyrian minutes.
This is a key that opens some sort of lock somewhere in the Ithrilis
temple of Xaventry. Not knowing what door the key opens doesn't help you
very much. Perhaps one of the clergy of the temple can help you find the
door it matches.
[*][SAFE]<3010hp 3286sp 2356st>
Now I have been able to get this mostly working using the following trigger:
<triggers>
<trigger
group="itemCapture"
lines_to_match="15"
keep_evaluating="y"
match="^You focus your powers of observation on (.+):\nItem '(?P<itemName>.+)' is type (.+), alignment ([\-0-9]+), made of (.+) \(in \((.+)\) condition\),\nhas keywords '(.+)'\.\nThis item weighs ([0-9]+) stones and ([0-9]+) pebbles, and is valued at ([0-9]+) gold\. \{Cat. [0-9]\}\nThis level ([0-9]+) item has the attributes: (.+)\n(This key may be used ([0-9]+ more time(|s)|an unlimited number of times))\.\n\*This item may be repaired (?P<repairCount>[0-9]+) times\.\n((?P<itemDescr>.*)\n)+\n$"
multi_line="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
ColourNote("silver", "black", "found item:")
ColourNote("silver","black","%<itemName>")
</trigger>
</triggers>
I basically set the lines to trigger to be a high number. The problem is, this has the potential to over capture at times, and if I simply send a blank line and get a new prompt back from the MUD, it results in the same trigger matching again. This wouldn't be a big deal, except that it keeps capturing the additional lines, when it should be breaking before the next prompt. There is a \n\n there, but each time I've tried putting that in at the end of my trigger match, the regex then seems to fail.
What am I missing here, or is there a better way of doing this when there could be variable length and count of lines?
Thanks in advance! |