Multi-line Trigger Question

Posted by Maelwys on Wed 23 Feb 2005 01:28 AM — 5 posts, 21,535 views.

#0
I have a trigger that I set up to highlight some text whenever it appears in the description of a room. The text is, basically:

A lovely birch tree is growing here.

and my trigger looks like this:

(a|an) (lovely|exotic|droopy|...) (birch|elm|maple|...) tree .*

The problem I run into is that this line can appear on one or 2 lines of the desc, so if the line breaks like this:

Blah blah blah blah blah. A lovely
birch tree is growing here.

my trigger won't fire. I've tried playing with the multi-line feature but it doesn't seem to make a difference. Anyone have any suggestions?

Cheers,
Maelwys
Amended on Wed 23 Feb 2005 01:33 AM by Maelwys
USA #1
Is it multiple lines because of a server linebreak? or just a wrap on the client end?

You cannot color a multiline trigger.
Poland #2
Quote:
You cannot color a multiline trigger.

Unless you write a small script, catching the input, gagging it and outputting it in colour.
#3
It's multiline because of a server newline. The room descriptions are set to only be a specific width no matter what your line width setting is.
Russia #4
This seems to do the trick:


import re

pat = re.compile("(glass(?: \x0d\x0a| )and(?: \x0d\x0a| )stonework(?: \x0d\x0a| ))")
col_pat = re.compile("(\x1B[\d+m)")

def OnPluginPacketReceived(strText):
    m = pat.search(strText)
    if not m:
        return strText
    else:
        start = m.start()
        end = m.end()
        part1 = strText[:start]
        part2 = strText[end:]
        colours = col_pat.findall(part1)
        last_colour = colours[len(colours)-1]
        part1 += "\x1B[31m"
        part2 = m.group(1) +last_colour + part2
        return part1+part2


That's Python however, as I don't want to try and mess with this in some other language. But maybe someone can translate it to Lua for you. It needs to go into a plugin, and you'll need to replace the three words ('glass', 'and', and 'stonework') with the groups that you want to actually match. This is just an example of how it can be done though, and doesn't pretend to be unversal in any way. It also won't help if your text is broken up between two packets, in which case nothing that I can think of can help, save for redrawing the entire output window by hand.