[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Multi-line Trigger Question
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Multi-line Trigger Question

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Maelwys   (2 posts)  [Biography] bio
Date Wed 23 Feb 2005 01:28 AM (UTC)

Amended on Wed 23 Feb 2005 01:33 AM (UTC) by Maelwys

Message
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
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #1 on Wed 23 Feb 2005 04:57 AM (UTC)
Message
Is it multiple lines because of a server linebreak? or just a wrap on the client end?

You cannot color a multiline trigger.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Scypio   Poland  (50 posts)  [Biography] bio
Date Reply #2 on Wed 23 Feb 2005 04:01 PM (UTC)
Message
Quote:
You cannot color a multiline trigger.

Unless you write a small script, catching the input, gagging it and outputting it in colour.
[Go to top] top

Posted by Maelwys   (2 posts)  [Biography] bio
Date Reply #3 on Wed 23 Feb 2005 04:23 PM (UTC)
Message
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.
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #4 on Wed 23 Feb 2005 07:37 PM (UTC)
Message
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.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


3,737 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]