Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ I can't seem to get this trigger working

I can't seem to get this trigger working

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


Posted by Ophianne   (7 posts)  Bio
Date Mon 22 Dec 2008 12:26 AM (UTC)
Message
I've been trying to color the channels in a mud a certain way. The line as it outputs to the mud goes like this:

Playername [channelname]: blahblah

Occasionally, the player will emote onto a channel and it'll look like this:

[channelname]: Playername does something

For wizzes, the brackets are replaced by <> and for race leaders it's replaced by {}.

I've tried looking at the example triggers but none of them work. My last effort was this:

^.+ \[sales\]\: .+$

And when I set it as *[channelname]* it only colors the first line of a multi-line channel comment. I'd like to get it to color to the end of the comment.

Any suggestions?

Thanks.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 22 Dec 2008 07:36 PM (UTC)
Message
It helps if you post the whole trigger, rather than excerpting it. See: http://mushclient.com/copying

One of your examples looks like a regular expression, the other doesn't. So I wonder if you had "regular expression" checked for the one that does.

The multi-line issue is another one again. Multi-line chats are fiddly to colour because MUSHclient processes each line as it arrives, and thus doesn't "remember" that a chat started a few lines back. It can be done with multiple triggers, one for the start of the chat, and one for the end, and making it colour whatever comes inbetween.

There is a fairly lengthy discussion about this at: http://mushclient.com/forum/?id=7991



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ophianne   (7 posts)  Bio
Date Reply #2 on Mon 22 Dec 2008 08:47 PM (UTC)
Message
Hiya:

Ok, for the first one (the nonworking one) I have:

<triggers>
<trigger
custom_colour="2"
enabled="y"
make_bold="y"
match="^.+ \[sales\]\: .+$"
sequence="100"
>
</trigger>
</triggers>

(sales is the name of the channel)

And for the second ones I have three examples:

<triggers>
<trigger
custom_colour="2"
enabled="y"
group="channelcolors"
make_bold="y"
match="*[retro]*"
sequence="100"
>
</trigger>
</triggers>

<triggers>
<trigger
custom_colour="2"
enabled="y"
group="channelcolors"
make_bold="y"
match="*&lt;retro&gt;*"
sequence="100"
>
</trigger>
</triggers>

<triggers>
<trigger
custom_colour="2"
enabled="y"
group="channelcolors"
make_bold="y"
match="*{retro}*"
sequence="100"
>
</trigger>
</triggers>

(where retro's the name of the channel)
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #3 on Mon 22 Dec 2008 11:07 PM (UTC)
Message
The first one, which doesn't work, looks like a regular expression. Try checking the "regular expression" checkbox.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ophianne   (7 posts)  Bio
Date Reply #4 on Wed 24 Dec 2008 09:01 AM (UTC)
Message
Works great! Thanks :-) I also made it more complex. For future searches, this is the full trigger (one trigger) and it's for RetroMUD:

<triggers>
<trigger
custom_colour="2"
enabled="y"
make_bold="y"
match="^.+ (\&lt;|\{|\[)(arena|chat|fflchat|gamerchat|genechat|mentor|retro|sales)(\&gt;|\}|\])\: .+$"
regexp="y"
sequence="100"
>
</trigger>
</triggers>

I think it covers most of the channels.
Top

Posted by Ophianne   (7 posts)  Bio
Date Reply #5 on Wed 24 Dec 2008 09:03 AM (UTC)
Message
Oh but I also have to tweak it a little for multiline and to cover emotes. I'll probably do it when I have more time.
Top

Posted by Ophianne   (7 posts)  Bio
Date Reply #6 on Tue 30 Dec 2008 03:24 AM (UTC)
Message
OK, still having a little trouble with the multi-line thing. The channel lines that come out don't have anything to wrap them with, so from what I understand I should make a new script file with this.

I currently have these two triggers:

<triggers>
<trigger
custom_colour="11"
enabled="y"
group="channelcolors"
make_bold="y"
match="^(\&lt;|\{|\[)(arena|chat|fflchat|gamerchat|genechat|mentor|retro|sales)(\&gt;|\}|\])\: .+$"
regexp="y"
sequence="100"
>
</trigger>
</triggers>

<triggers>
<trigger
custom_colour="11"
enabled="y"
group="channelcolors"
make_bold="y"
match="^.+ (\&lt;|\{|\[)(arena|chat|fflchat|gamerchat|genechat|mentor|retro|sales)(\&gt;|\}|\])\: .+$"
regexp="y"
sequence="100"
>
</trigger>
</triggers>

So they work fine and cover all of the stuff that comes out of the channels except for multi-line. Now for multi-line I believe I'm supposed to use something a trigger and a script?

<trigger
enabled="n"
match="*"
script="redirect"
name="multi_line_chat"
sequence="10"
>
</trigger>

<script>
<![CDATA[
chat_world = "retro"
local first_time = true

function redirect (name, line, wildcards, styles)

-- try to find "chat" world
local w = GetWorld (chat_world) -- get "chat" world

-- if not found, try to open it
if first_time and not w then
local filename = GetInfo (67) .. chat_world .. ".mcl"
Open (filename)
w = GetWorld (chat_world) -- try again
if not w then
ColourNote ("white", "red", "Can't open chat world file: " .. filename)
first_time = false -- don't repeatedly show failure message
end -- can't find world
end -- can't find world first time around

if w then -- if present
for _, v in ipairs (styles) do
w:ColourTell (RGBColourToName (v.textcolour),
RGBColourToName (v.backcolour),
v.text)
end -- for each style run
w:Note ("") -- wrap up line

end -- world found

-- if ends with quote, end of multi-line chat
if line:sub (-1) == '"' then
EnableTrigger ("multi_line_chat", false) -- no more lines to go
else
EnableTrigger ("multi_line_chat", true) -- capture subsequent lines
end -- if

end -- function redirect

]]>
</script>

So the trigger...calls the script? Is that it? I know I'm probably doing something wrong here but I've never worked with scripting before and have no idea what's going on; I'm not trying to send the chats to a new window, just color them the same way as the first 2 triggers.

Thanks.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #7 on Tue 30 Dec 2008 03:58 AM (UTC)
Message
That looks too complex to me. Can you give an example of a multi-line chat? How is the client supposed to know when the multiple lines end (for example, a trailing period)?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Yanwuhuan   (15 posts)  Bio
Date Reply #8 on Tue 30 Dec 2008 06:57 AM (UTC)
Message
I can not see any script in group "channelcolors".
So which trigger will invoke redirect to enable trigger "multi_line_chat"?

Below is my rob, almost same with yours.
function redirect_begin, invoked by "channelcolors" trigger group,
redirect the current chat line, judge whether I should enable "multi_line_chat".

function redirect, invoked by "multi_line_chat" trigger,
redirect any line, disable self if received line:sub (-1) == '"'
Top

Posted by Ophianne   (7 posts)  Bio
Date Reply #9 on Tue 30 Dec 2008 07:39 AM (UTC)
Message
Sure, a multi-line comment would be something like this:

[retro]: Rauul has faith that Ruckus will do well with

necro.. and i have enough gold and dues to test/bug every skill/spell in the new necro

It would color the first line up until "with" orange (I skipped the line to delineate) and then after that everything would still be the normal color.

For the script/trigger, I actually pulled it from the link above http://mushclient.com/forum/?id=7991 and just changed the world name around I think. (It's your post at Wed 27 Feb 2008 01:12 AM (UTC))
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #10 on Tue 30 Dec 2008 09:03 AM (UTC)
Message
OK, well my problem with your example lines are, it isn't too easy to tell that it is a multi-line chat. We humans can tell that sentences don't normally end with "with" and so we read on to see if the next line makes sense.

But for a machine-based trigger, you haven't shown me anything that forms some kind or "rule" that the client can use to treat the next line as part of the chat.

For example, a rule might be that:


  1. A multi-line chat does not end with a period on the first line.
  2. The multi-line chat ends when there is a period on the second or subsequent lines.


However your example had no such period.

One thing to look into is that some servers let you set up the maximum line length, and then the server adds a newline character when that is reached. If you can defeat that (eg. set to zero, or a very large number) then multi-line chats are really single lines, that the client wraps for you. In that case, the whole wrapped line will be coloured by a simple trigger.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


28,933 views.

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

Go to topic:           Search the forum


[Go to top] top

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