This post elaborates on techniques described elsewhere to make a separate window to filter chat (or any) messages to.
To make the explanation reasonably simple, I am hard-coding in the name of the chats world. You can modify that to be the name of the world (MUD) that you want to use. The name isn't really all that important.
First, let's make a new MUSHclient world window, which is going to receive chat messages.
Go to the Connection menu -> Quick Connect (Ctrl+Alt+Shift+K).
Enter a "chat" world name ... I used "RoD chats", but you can use anything, provided you modify the plugin slightly.
Enter "0.0.0.0" for the TCP/IP address - this stops MUSHclient from trying to actually connect to this world.
Hit OK to create this world.
Press Ctrl+G or Alt+Enter to enter the world configuration, and change the font size (in Appearance -> Output) to be small enough to fit the chat window on your screen alongside the main world. Maybe change the "wrap column" to be smaller if necessary.
Go to the File menu -> Save World Details (Ctrl+S).
Save as the suggested name "RoD chats.mcl".
You now have somewhere for the chats to appear. You can move it to one side, to make room for the "real" world window.
Now we need to redirect appropriate chat messages (eg. say, tell, yell, etc.) into the other window. To do this, go to the "main" world (the one that connects to the MUD), and copy the plugin below, paste into a blank notepad window, and save as Chat_Redirector.xml.
If you called your chat world something different from "RoD chats", change the single line:
chat_world = "RoD chats"
... to be the name you chose.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, June 30, 2007, 10:48 -->
<!-- MuClient version 4.13 -->
<!-- Plugin "Chat_Redirector" generated by Plugin Wizard -->
<!--
Edit plugin and change "chat_world" variable to be the name of the
world you want chats to go to.
-->
<muclient>
<plugin
name="Chat_Redirector"
author="Nick Gammon"
id="cb84a526b476f69f403517da"
language="Lua"
purpose="Redirects chat messages to another world"
date_written="2007-06-30 10:45:35"
requires="4.08"
version="1.0"
>
<description trim="y">
<![CDATA[
Redirects chats to the specified world.
Add or modify "chat" triggers to capture different sorts of message.
Change the variable "chat_world" to be the name of the world chats are to go to.
]]>
</description>
</plugin>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
match="^[A-Za-z]+ (says|chats|yells) \'(.*?)\'$"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="^You (say|chat|yell) \'(.*?)\'$"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>
</triggers>
<!-- Script -->
<script>
<![CDATA[
chat_world = "RoD chats"
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
end -- function redirect
]]>
</script>
</muclient>
You may need to edit the triggers above to reflect how chats appear in your MUD. The example above catches "say", "chat" and "yell", but you probably want to add things like "whisper", "tell", etc. depending on your MUD.
If you want the messages to only appear in the other window, and not the main window, add this line to (both) triggers:
omit_from_output="y"
In other words, the first trigger would now look like this:
And, the second one would be amended in the same way.
You can now use the File menu -> Plugins, to install this new plugin.
Once installed, as soon as a chat message causes the trigger to fire, it should attempt to locate the "chat" world, and send the chat to it. Any colouring in the chat message should be preserved.
If the chat world is not open, the plugin attempts to open it for you. This functionality is only available in version 4.08 onwards of MUSHclient, so you will need to install that.
With suitable resizing of both windows, it should be possible to see chats, and the "main" world messages, at the same time.
If you want to be able to enter chat commands into the input area of the chat window (as well as the main window) then you can add this plugin below to the chat world (ie. "Rod chats" in this case).
What this does is detect player input (using OnPluginCommandEntered), and then try to find the "main" world (called "RoD" in this case), and send the command back to that world for execution.
This way, you chould chat away in the chats window, and leave moving and fighting for the main window.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, June 30, 2007, 10:14 -->
<!-- MuClient version 4.13 -->
<!-- Plugin "Redirect_Input" generated by Plugin Wizard -->
<muclient>
<plugin
name="Redirect_Input"
author="Nick Gammon"
id="fefa658aa8caca3cb5e2fa81"
language="Lua"
purpose="Redirects commands to another world"
date_written="2007-06-30 10:08:32"
requires="4.00"
version="1.0"
>
</plugin>
<!-- Script -->
<script>
<![CDATA[
world_name = "RoD"
function OnPluginCommandEntered (command)
local w = GetWorld (world_name) -- find world
-- not found? show error
if not w then
ColourNote ("white", "red", "World " .. world_name .. " is not open")
else
w:Execute (command) -- execute command (handle aliases, etc.)
PushCommand (command) -- save in command history
end -- if
return ("\t") -- clear command
end -- OnPluginCommandEntered
]]>
</script>
</muclient>
Works great. :) I did have trouble changing or adding message types though. Example changing chat/chats to whisper/whispers seems to have no effect even after reinstalling.
Double check the regex for that. It is set up to capture the line only if what is said is encapsulated in single quotes. I have been slowly adding channel captures to a plugin I use for Aardwolf, and the part that takes the longest is properly designing what the triggers fire off of.
Shaun, I already have created a plugin in Lua for just that thing, channel captures, and it is quite user friendly, and allows toggling of it being omitted from the main window, as well as a swear filter, for those that have children that play on the server as well.
I need to update my installer, to put in my latest alteration of the swear filter (sped it up 5X)
Let me know if you would like to take a looksie at it :)
Eh, I already made mine, and it works great. And I think having a swear filter on my clan channel would just result in dead silence :p We really aren't that bad, but the swear filter is actually a nice idea, it can be done with just a simple sub. My only issue so far is adding the various class talks, since I have not bothered to add any except for the cleric and warrior pclasses. Oh, and gclan is a pain, so I skipped that... I should fix that soon.
Well actually it does not kill the entire line, it only replaces swears with asterisks, as requested by someone on the mud, cause his children played on the mud.
And you might want to have a look at it, cause who knows you might find something to add to your own plugin.
I am having the worst time getting this plugin to work. I play Achaea, the world name set for it is Achaea. I followed the instructions to create a new world for ROD Chats. 0.0.0.0 port:4000. I first didn't adjust any of the plugin, and simply said something to see if anything would pop up. Nothing did. I adjusted it to my city channel, to no effect. I also tried adjusting the names of the chats, no to effect. I'm not very failiar with regex expressions so that could be my problem. The redirect input plugin worked just fine, I could type text in the chat world window and have it go to my main world. I just get no text from my main world to the chat window.
I'm using this just for tells and my city channel. To show an example:
(Shallam): Andy says, "Please help me."
You tell Initiate of Air, Johnny, "Thanks."
Johnny tells you, "Anytime."
You didn't show the regexp you were trying, however that is almost certainly the problem. For one thing, my example used single quotes, but your examples had double quotes. Triggers are very picky about things like that.
I got your examples to work by modifying the triggers part of the plugin to be this:
I have allowed for an optional channel name (is that what Shallam is?) in brackets, followed by "says", "yells" or "tells you". You can add more words to the regexp by following the general idea above.
I have changed from single to double quotes.
The outgoing chat message also has been amended for double quotes. You might need to modify that a bit for doing a "say" or simply add another trigger.
Thanks Nick, it's working great! There's only one issue that I'm struggling with and I found the information to fix it but I can't figure out how to implement it. Multi-line support. With Achaea there's a server-side line feeds that break up each line after so many characters. What happens is when there's a two line message or tell, it doesn't show up in the other "chat" world at all. I believe this is because it doesn't catch the quotation mark at the end. I found this script you made for this very reason, just not sure how to plug it in to the setup on this post. Here's the script and trigger -
Hmm, multiple lines eh? I don't suppose you can make Achaea not wrap?
Anyway, I modified my plugin a bit to handle multiple lines. The changed lines are in bold.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, June 30, 2007, 10:48 -->
<!-- MuClient version 4.13 -->
<!-- Plugin "Chat_Redirector" generated by Plugin Wizard -->
<!--
Edit plugin and change "chat_world" variable to be the name of the
world you want chats to go to.
-->
<muclient>
<plugin
name="Chat_Redirector"
author="Nick Gammon"
id="cb84a526b476f69f403517da"
language="Lua"
purpose="Redirects chat messages to another world"
date_written="2007-06-30 10:45:35"
requires="4.08"
version="1.0"
>
<description trim="y">
<![CDATA[
Redirects chats to the specified world.
Add or modify "chat" triggers to capture different sorts of message.
Change the variable "chat_world" to be the name of the world chats are to go to.
]]>
</description>
</plugin>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
match="^(\(.+\): )?[A-Za-z]+ (says|yells|tells you), ".+"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="^You (tell|whisper) .+, ".+"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>
<trigger
enabled="n"
match="*"
script="redirect"
name="multi_line_chat"
sequence="10"
>
</trigger>
</triggers>
<!-- Script -->
<script>
<![CDATA[
chat_world = "RoD chats"
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>
</muclient>
I am not using a multi-line trigger, because these don't remember colours, and my original plugin kept the colouring.
What I have done is removed the final quote from the chat match, so they will match whether or not the closing quote is there.
Then in the script I check if the very last character is a quote - if so, that must have been the last line of the chat.
However if not, then it enables a third trigger which has the name "multi_line_chat". This third trigger (initially disabled) matches everything (hence the match="*"). This is designed to match anything that follows the start of a multi-line chat. In the script, if a subsequent line ends in a quote, then this extra trigger is disabled again.
This lets you "push through" stuff like it was arriving from the MUD. I usually use that to test triggers for people (from your examples) rather than having to log onto a specific MUD.
I figured out quite a few things I can do with multiple extra windows. Health bar, etc. One thing I'm trying to do is a who list, but I'm having trouble with the multiline portion. Right now it's set up to end at quote, I'm trying to get it to end at prompt.
Member Rank HTell HNTell Probation Class
------ ---- ----- ------ --------- ------
Player 08 On On No Magi
Player 01 Off On Yes Sylvan
Player 09 On On No Magi
Player 03 On On No Magi
Player 01 Off On Yes Magi
2773h, 1382m exb-
I tried to plug in the regex for my prompt at
"if ends with" Though the regex didn't work, I've tried a few other things but just am not sure to where to plug it in.
This is the regex for my prompt
^(.*?)h\, (.*?)m(.*?)$
the "exb-" is constantly fluctuating with the only constant being the hyphen. Though with the underlines under Member Rank, etc. That cancels out using a hyphen as a line ending.
I think the blank line happened when I posted it to the forum, this is what it looks like.
Upper right hand corner
http://img442.imageshack.us/my.php?image=hwhoxg8.jpg
Edit: Just realized I posted the thumbnail, oops. Fixed.
Well you just need to match in this case on the start of the line, rather than trying to guess the last character.
I assume you are using a different function for you who list? You are redirecting to a different window, so I presume so.
Instead of:
if line:sub (-1) == '"' then
EnableTrigger ("multi_line_chat", false) -- no more lines to go
You could have something like:
if string.match (line, "^%d+h,") then
EnableTrigger ("multi_line_chat", false) -- no more lines to go
In other words, if a line comes along that starts with some numbers followed by "h," it is time to stop.
Your other problem here is that this is a line you don't want to see, so you want to move the test further up (before the line is copied to the other window).
If you are in fact making multiple copies of the redirect function I would personally be making the middle bit (that copies the lines) into a separate function, to save repeating something that will be the same in each case.
Thanks again Nick, it works great. I actually tried to get it to do something like this by I was going about it all wrong in my ignorance of proper scripting.
I tried to change
-- if ends with quote, end of multi-line chat
to
-- if starts with 2, end of multi-line chat
if line:sub (-1) == '^2(.*?)$' then
Among several different attempts. I suppose I really need to learn Lua. On that note, do you have any reccomendations on books or websites to that effect? It seems like vbscript book I had (which I didn't realize until just the other day) focuses mostly on utilizing scripting in web sites. I have a basic understanding of C...
PS: Also, when you suggest changing the fuction do you mean this?
-- if starts with 2, end of multi-line chat
if line:sub (-1) == '^2(.*?)$' then
That wouldn't work because you are using a regular expression where a simple comparison is being done. You need to look up string.sub in the MUSHclient help - that pulls out a substring, and -1 means the last column (however 1 means the first column). The last column would never match '^2(.*?)$' (for one thing, that is more than one byte).
Quote:
do you have any reccomendations on books or websites to that effect?
See: http://www.lua.org/docs.html
The book "Programming in Lua" by Roberto Ierusalimschy (one of the authors of Lua) is really well-written. That page also leads to links for online documentation.
Quote:
Also, when you suggest changing the fuction do you mean this?
Yes - the example below replaces my original script portion with two "redirect" functions - one for chats and one for the who list. They share the function send_to_window - which does the actual copying of text to the other window, because this will be the same in both cases (or for more cases again, as your screen dump seems to show).
You can see that in who_list_redirect I test for the end of the list first, so that the prompt line does not end up in the other window.
As a general rule I like to simplify things that are done repeatedly, rather than copy-and-paste, because if you ever find a problem then you only need to fix it in one place.
local tried_to_open = {} -- set flag if can't open world
function send_to_window (chat_world, styles)
-- try to find "chat" world
local w = GetWorld (chat_world) -- get "chat" world
-- if not found, try to open it
if not tried_to_open [chat_world] 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)
tried_to_open [chat_world] = true -- 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
end -- send_to_window
-- chat redirector
function chat_redirect (name, line, wildcards, styles)
send_to_window ("Chats", styles)
-- 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 chat_redirect
-- who list redirector
function who_list_redirect (name, line, wildcards, styles)
if string.match (line, "^%d+h,") then
EnableTrigger ("multi_line_who", false) -- no more lines to go
return -- don't copy line
else
EnableTrigger ("multi_line_who", true) -- capture subsequent lines
end -- if
send_to_window ("Who list", styles)
end -- function who_list_redirect
The whole thing works fine for me except for one minor issue. When a multi-line chat message comes into MUSHclient, it gets redirected to RoDchats as expected. However, the terminating CRLF gets processed in *both* windows, resulting in an unwanted status line in the main window (just as if I hit ENTER by itself).
I've installed v4.23, and revised the regex (which might be problem). The trigger code I'm using now is:
That doesn't look right - that will match OOC followed by zero or more right brackets. Perhaps you mean:
Quote:
match="^\(OOC\).*"
Anyway, I don't see how that is your problem. I gather you are saying you have a prompt line, which the chat then terminates (so this is the initial newline actually), and although the chat is moved to another window you still have the prompt, is that it?
I'm not sure of an easy solution, but one would be to match the prompt line, and discard it if it is the same as the 2nd last line. Something like this could do the trick:
<triggers>
<trigger
enabled="y"
match="<*hp *m *mv> <#*>*"
send_to="14"
sequence="100"
>
<send>
if GetLineInfo (GetLinesInBufferCount () - 1, 1) == "%0" then
DeleteLines (1)
end -- same as previous line
</send>
</trigger>
</triggers>
You could need to modify the match part to be the same as your prompt. Now this should omit multiple prompts which are identical to the previous one.
I confused myself by naming two different things the same in my earlier example. This is the amended plugin that handles chats, and omits the original chat from the main window:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, June 30, 2007, 10:48 -->
<!-- MuClient version 4.13 -->
<!-- Plugin "Chat_Redirector" generated by Plugin Wizard -->
<!--
Edit plugin and change "chat_world" variable to be the name of the
world you want chats to go to.
-->
<muclient>
<plugin
name="Chat_Redirector"
author="Nick Gammon"
id="cb84a526b476f69f403517da"
language="Lua"
purpose="Redirects chat messages to another world"
date_written="2007-06-30 10:45:35"
requires="4.08"
version="2.0"
>
<description trim="y">
<![CDATA[
Redirects chats to the specified world.
Add or modify "chat" triggers to capture different sorts of message.
Change the variable "chat_world" to be the name of the world chats are to go to.
]]>
</description>
</plugin>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
match="^(\(.+\): )?[A-Za-z]+ (says|yells|tells you), ".+"
regexp="y"
script="chat_redirect"
omit_from_output="y"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="^You (tell|whisper) .+, ".+"
regexp="y"
script="chat_redirect"
omit_from_output="y"
sequence="100"
>
</trigger>
<trigger
enabled="n"
match="*"
script="chat_redirect"
name="multi_line_chat"
omit_from_output="y"
sequence="10"
>
</trigger>
</triggers>
<!-- Script -->
<script>
<![CDATA[
chat_world = "RoD chats"
who_world = "Who List"
local tried_to_open = {} -- set flag if can't open world
function send_to_window (world_name, styles)
-- try to find "chat" world
local w = GetWorld (world_name) -- get "chat" world
-- if not found, try to open it
if not tried_to_open [world_name] and not w then
local filename = GetInfo (67) .. world_name .. ".mcl"
Open (filename)
w = GetWorld (world_name) -- try again
if not w then
ColourNote ("white", "red", "Can't open chat world file: " .. filename)
tried_to_open [world_name] = true -- 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
end -- send_to_window
-- chat redirector
function chat_redirect (name, line, wildcards, styles)
send_to_window (chat_world, styles)
-- 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 chat_redirect
-- who list redirector
function who_list_redirect (name, line, wildcards, styles)
if string.match (line, "^%d+h,") then
EnableTrigger ("multi_line_who", false) -- no more lines to go
return -- don't copy line
else
EnableTrigger ("multi_line_who", true) -- capture subsequent lines
end -- if
send_to_window (who_world, styles)
end -- function who_list_redirect
]]>
</script>
</muclient>
I tried this new version, and it has a strange result. When I first start up the two windows, everything works. However, as soon as a chat is redirected to the RoD Chats window, ALL subsequent output from commands given in the main window appears in RoD Chats. Chat output from other players continues to appear in RoD Chats, too.
Oh, I have this issue from time to time. At some points in the game the plugin will catch some text that confuses it, something with a few quotations in it I believe. Once it sees that it redirects everything to the secondary output window. I've been able to fix this just by saying something. It catches the quotes and stops sending everything to the output.
An example of a chat would help. The critical thing to get right is the function that detects when a chat is over. If that is wrong, it thinks everything is part of the chat.
This is the important part (near the end of the plugin):
-- 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
This is cancelling the redirection when it gets a line ending in a double-quote. (The expression line:sub (-1) means the very last character).
If your line ends in a single quote, it would need to read instead:
-- 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
That might look the same but it is a single quote inside double quotes, rather than a double quote inside single quotes.
It might be more readable like this:
-- 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
Now you can see the quote more easily.
You really need to closely look at the way chats are shown. For example, if it ends with double quote, period, like this:
Nick tells, you "hello".
Then you need to catch the period too. For example:
-- if ends with quote, end of multi-line chat
if line:sub (-2) == [[".]] then
EnableTrigger ("multi_line_chat", false) -- no more lines to go
else
Notice the -1 has become -2, which means the last 2 characters on the line.
(OOC) Textor: Uh, ok. Well, one day a spider was walking along the forest. Then, this big, mean person started beating him with a newspaper. The spider was in pain, mangled from the beating, but he bit the abusive person. The End.
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night
inv
You are carrying nothing.
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night
(OOC) Namino blinks.
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night
Multiline chats do not have newlines -- they just wrap in the client window.
The next line after the chat always begins with 'H:'
I want that entire line to be ignored. But if it showed up in the chat window it would be OK.
The status line can end with any of a number of time strings -- about 35 different possibilities.
The line in the middle of the example, starting with 'inv', is a line (together with the following resulting line or lines) that should not be sent to the chat window.
If the chats are a single line, wrapped by the client, then you don't need all this complexity. Just use the plugin from page 1 of this thread, which assumed the chat was one line. You need to amend the matching regexp, that is all.
Until you suggested a closer look at the MUD output, I had not realized that my "multi-line" chats were, in fact, just one-liners with wrapping. So, I went back to the simple plugin as you suggested.
However, my original problem still persists, that the chat output itself goes to the RoD Chats window, but a newline is processed in the main client window, which results in a status display line. (That's the default action for a blank CRLF).
Hmmm. OK. Given the response, I'll ask a different question.
Given that I receive two lines from the mud, like this
(OOC)Sometext \n
H:Status \n
How do I suppress the newline (\f or \r or \n, I don't know which) in the original window when I send the text to the RoD Chats window?
I've tried a simple trigger (to omit from output) based on ^H:.* and it suppresses everything except the new line. (That is, when status line comes from MUD, I end up with a blank line in the client main window.)
Sorry to be dense... And thanks for your patience and help.
That will omit every blank line you get (except ones you type yourself). To make this work you must go to File -> Global Preferences -> General and check "Regular expressions can match on an empty string".
To simplify this, version 4.28 now has a "getworld" module. The plugin could now look like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, June 30, 2007, 10:48 -->
<!-- MuClient version 4.13 -->
<!-- Plugin "Chat_Redirector" generated by Plugin Wizard -->
<!--
Edit plugin and change "chat_world" variable to be the name of the
world you want chats to go to.
-->
<muclient>
<plugin
name="Chat_Redirector"
author="Nick Gammon"
id="cb84a526b476f69f403517da"
language="Lua"
purpose="Redirects chat messages to another world"
date_written="2007-06-30 10:45:35"
requires="4.08"
version="2.0"
>
<description trim="y">
<![CDATA[
Redirects chats to the specified world.
Add or modify "chat" triggers to capture different sorts of message.
Change the variable "chat_world" to be the name of the world chats are to go to.
]]>
</description>
</plugin>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
match="^(\(.+\): )?[A-Za-z]+ (says|yells|tells you), ".+"
regexp="y"
script="chat_redirect"
omit_from_output="y"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="^You (tell|whisper) .+, ".+"
regexp="y"
script="chat_redirect"
omit_from_output="y"
sequence="100"
>
</trigger>
<trigger
enabled="n"
match="*"
script="chat_redirect"
name="multi_line_chat"
omit_from_output="y"
sequence="10"
>
</trigger>
</triggers>
<!-- Script -->
<script>
<![CDATA[
chat_world = "RoD chats"
who_world = "Who List"
require "getworld" -- handles finding the world, and sending the line
-- chat redirector
function chat_redirect (name, line, wildcards, styles)
send_to_world (chat_world, styles)
-- 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 chat_redirect
]]>
</script>
</muclient>
I have multiple worlds reporting to the same window, using the plugin on the first page.
And I'm just wondering, how can i record what world it originated from, and possibly timestamp it.
For example. lets say i have 3 worlds. A B and C
A is the Chat_world
and i get a message on B, instead of
Whoever tells you 'whatever'
being sent to the chat_world it would show something like
(Recieved from B, at Hour/minute) Whoever tells you 'whatever'
The first page? Well in the middle is the stuff that sends the text:
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
You would need to change it to something like:
if w then -- if present
w:ColourTell ("white", "", "Received from: " .. WorldName ())
w:ColourTell ("white", "", os.date (" at %H:%M : "))
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
Hi. I'm a newbie to all of this, and well I'm having issues with the plugin. Everytime someone says something I get a huh? in my main window. I copied the plugin as directed, but I used my own triggers, just adjusted them as needed.
I'm not sure what i've done wrong to keep getting this huh? across my screen.
These are my triggers, maybe this is where the problem is? I set it up to move pages, and channel chats.
<script>
<<Arkanian>: Hrm
CommNet 1 [Soal]: hrm
[- AdasCorp -]{Arkanian Engineering}<Junior Technician>[Soal]( moodily )<Arkanian>: test
Theese are some examples, how do I isolate just say and NEWBIE, OOC, IMM, and [- AdasCorp -] as well as possibly Commnet.
I wouldn't try to make one trigger to catch all those lines I'd try to make triggers to catch each type or how ever it
breaks down best.
This trigger is not a regular expression it just uses * to match anything between the two single quotes.
Matches: You moodily say 'some text between single quotes'
<trigger
enabled="y"
match="You moodily say '*'"
regexp="n"
script="redirect"
sequence="100"
>
</trigger>
If you can identify words that start a chat line and are not going to appear at the beginning of any other lines
the MUD will send you can make a general trigger like this.
Matches: You moodily say 'some text between single quotes'
: You angrily say 'some text between single quotes'
<trigger
enabled="y"
match="You * say '*'"
regexp="n"
script="redirect"
sequence="100"
>
</trigger>
Thanks much, the multi triggers works wonders. I messed up at first but I did not notice to set reg expression to n from y. I fixed it and I am loving every minute of it.
One thing I have noticed and this is mush in general I think...
When I add the line
omit_from_output="y"
it will gag it from my main window but I still get a blank line in my scrolling.
Is there a way to fix this?
This is because what is happening is that the trigger matches and omits the line, but the MUD is helpfully sending an extra blank line, which the trigger doesn't match.
I found this hard to fix for the individual matches (sometimes the blank lines were there and sometimes not), so I just use the plugin below that suppresses *all* blank lines.
There is a discussion about it somewhere else on this forum.
To save and install the Omit_Blank_Lines plugin do this:
Copy the code below (in the code box) to the Clipboard
Open a text editor (such as Notepad) and paste the plugin code into it
Save to disk on your PC, preferably in your plugins directory, as Omit_Blank_Lines.xml
The "plugins" directory is usually under the "worlds" directory inside where you installed MUSHclient.
Go to the MUSHclient File menu -> Plugins
Click "Add"
Choose the file Omit_Blank_Lines.xml (which you just saved in step 3) as a plugin
Click "Close"
Save your world file, so that the plugin loads next time you open it.
Alright, it took me a while to figure it out, but I finally got the new worlds to open up and everything. My only problem is that I can't see to get color-based triggers to carry over.
For instance, if I disable the plugin that allows the chat worlds to open, pages show up color coded... one for incoming, another for outgoing. When the plugin is enabled, however, the colors are gone.
I've even tried to make a set of triggers for the new world, as well, with no luck.
What version of MUSHclient are you using? Version 4.43 may possibly fix this, as the style run colours sent to triggers are the updated ones as amended by other triggers.
How would I go about making the multi-line trigger activate over a line that didn't end in punctuation? I know it leaves this pretty open, but the only true indicator on the MUD I play that somebody's chat message has ended is that it ended with a form of punctuation, usually a period it throws on the end if somebody forgot (or was simply too lazy) to add one themselves.
Edit: Thinking of the English language itself, it should probably also trigger from lines that end with a comma, due to the fact it indicates that only a portion of the sentence has passed.
In that thread, a little way down the page, I describe how to handle multi-line chats, and sending to another window. Rather than using a single multi-line trigger it uses a couple of triggers, where the start of a chat activates a second one.
In the multi-line example, it keeps processing chats until they end with a double-quote (by a simple search). You would just modify that to keep processing until they do *not* end with punctuation. Otherwise conceptually it would be very similar.
You just linked me back to the start of this post. I don't really know how to go about changing it to only end on punctuation. I tried just throwing everything except ' into the script and I just got errors, so now I've got it sitting on a period.
Well, this part on page 1 looks for the end of a multi-line chat:
-- 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
That is testing the last character of each line for the double-quote character. Now if you say a multi-line chat ends on a period or question-mark or something, you change it to:
-- if ends with period or question-mark, end of multi-line chat
if line:sub (-1) == '.' or 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
Now if that doesn't work, can you post what you did exactly, and what the lines from the MUD are?
And if you get errors, rather than saying "I got errors" can you post the exact error message, and what your code was that caused it?
Sighh.. I'm really new at this. All I want it to do is match (<the name of any of the various guilds, cities, or clans>): <someone> says, "<something>" and pipe it to a new window. Also not to match regular <person> says, only group ones. But I can't figure out how because this is rather too complicated for my tiny brain.
Ive followed the directions to a tee, I play midkemia, I cannot get anything to send from the main world to the chat window.. I'm copyin and pastin, enabling the plug in and nothing.. I dunno what to say.. past frustrated.. i like the client but nothing seems to work for me. Any help would be great.
To help both of you we need to see, copied and pasted (not just described) the exact output from the MUD you want to match (and any similar output you want to not match).
Also, if you changed the plugin can you at least post the changed lines (or all of it?).
Regular expression matching can be fiddly to get right, an extra space somewhere and it won't match.
<script>
<![CDATA[
chat_world = "RoD chats"
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
I dunno, its like these triggers take a minute to warm up :-) started workin normally the way i wanted after changed that line in the trigger, and played for 5-10min. Thanks Worstje
I've really been trying to get this to work, but I can't. Basically, I want to match any line that has something surrounded by ' ' regardless of where it comes in the line. I tried '*' but it seems to pickup any line with a ' in it, even if there's only one. Can someone please help?
This is what is picking up anything with a ' instead of surrounded by them, as I would expect.
Oops. I saw two posts an hour apart on an old thread last posted to in February 2010, and just assumed they were from the same person, particularly as they were both about quote symbols. You notice my reply actually quotes Slowreflex's trigger but uses Verdilak's test data. So it was sort-of a "combined reply".
Slowreflex : can you please post the actual trigger you used?
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.
Also the actual line from the MUD you are trying to trigger on?
Verdilak : can you please post the trigger you used as well? (See copying advice above).
This is a 5-page thread, and there are a few variations on the plugin and suggested trigger in those pages, so it is hard to give advice without seeing what you are actually using.
I've really been trying to get this to work, but I can't. Basically, I want to match any line that has something surrounded by ' ' regardless of where it comes in the line. I tried '*' but it seems to pickup any line with a ' in it, even if there's only one. Can someone please help?
This is what is picking up anything with a ' instead of surrounded by them, as I would expect.
The problem is of course it picks up words like can't and don't in the room descriptions but this is the only way I can get it to pickup the actual chat.
Examples,
Jimbob [OOC]s, 'oh lol '
You say, 'hmm'
You ask, 'hmm?'
You exclaim, 'hmm!'
Jimbob sends a scouter transmission to you, 'What do you want?'
I think I figured it out- The "chat world" name wasn't "RoD chats", I think when I saw this part I thought it was the file name. I've been working on this late at night when I actually have time, so I'm bound to make mistakes like that.
I'm at work right now so when I get home I'll modify the code so that the line: chat_world = "PKFusion" is added replacing the "RoD chats".
I'll let you know how it goes,
Thanks for the response,
Nick Gammon said:
•Enter a "chat" world name ... I used "RoD chats", but you can use anything, provided you modify the plugin slightly.
•Enter "0.0.0.0" for the TCP/IP address - this stops MUSHclient from trying to actually connect to this world.
•Hit OK to create this world.
•Press Ctrl+G or Alt+Enter to enter the world configuration, and change the font size (in Appearance -> Output) to be small enough to fit the chat window on your screen alongside the main world. Maybe change the "wrap column" to be smaller if necessary.
•Go to the File menu -> Save World Details (Ctrl+S).
•Save as the suggested name "RoD chats.mcl".
On a side note, I'm very excited about using this program once I can learn how it works.
Thanks,
to be transferred to the other window, playing Hatemoo. I don't want them shown on the main window either. How can I accomplish this? It's not working too well...
[zotnet] Bobby asks, "Have you ever met a gangster that wasn't cool?"
On your wristpad radio: [cam-Apt 321] On the CRT television: This just in: A rioting mob of indigenous mutants is growing in numbers in the Necropolis!
[zotnet] Bobby asks, "Have you ever met a gangster that wasn't cool?"
On your wristpad radio: [cam-Apt 321] On the CRT television: This just in: A rioting mob of indigenous mutants is growing in numbers in the Necropolis!
They're also different colors and such, if possible, though it seems complicated to do with this system. Example:
On your wristpad radio: [yellow][cam-Apt 101][/yellow] [green]On the CRT television: This just in: A rioting mob of indigenous mutants is growing in numbers in the Necropolis![/green]
On your wristpad radio: [yellow][cam-Apt 101][/yellow] The [B]ham radio: [red][FCPD][/red]The scrawny hound earned 8 stars at Fourth and Grand.[B]
[red][zotnet][/red] Bobby asks, "Have you ever met a gangster that wasn't cool?"
Brackets and colors are the colors they appears as normally, [B] is bolded white text.
Hi, I'm trying to filter out the following to a new window:
Quote: =====================<+CDB Info for Jan (1473) - Male PC>=====================
Fullname: Jan Marbrand
Family: Son of Ser Joslan Marbrand and Janysa Falwell. Unmarried.
Age: 22 (b. 9-11-140) Religion: The Seven
House: Marbrand Allegiance: Marbrand
Region: The Westerlands Location: King's Landing
------------------------------------------------------------------------------
Status: A scion of a lesser lordly house.
Title: Knight
------------------------------------------------------------------------------
Hair: Dark Auburn Height: 1.88m/6'02"
Eyes: Grey Weight: 80kg/176lbs
Shortdesc: A rangy young man with dark auburn hair and grey eyes, clad in
simple but fine clothing.
==============================================================================
This is my code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, May 31, 2012, 4:48 PM -->
<!-- MuClient version 4.73 -->
<!-- Plugin "CBDRedirect" generated by Plugin Wizard -->
<muclient>
<plugin
name="CBDRedirect"
author="NY"
id="2a58766aa2f7611113dbbcbc"
language="Lua"
purpose="To redirect CDB"
date_written="2012-05-31 16:48:13"
requires="4.73"
version="1.0"
>
</plugin>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
match="CDB"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>
<trigger
enabled="n"
match="*"
omit_from_output="y"
script="redirect"
name="multi_line_chat"
sequence="10"
>
</trigger>
</triggers>
<!-- Script -->
<script>
<![CDATA[
chat_world = "BoD cdb"
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
-- 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 -- world found
end -- function redirect
]]>
</script>
</muclient>
I can get it to filter the text I want, but after that it filters everything else coming from the 'main' world. Am I missing a command to switch the multi-line filter off?
Having a slight problem; I'm trying to filter out emotes on channels as well, but it isn't catching them because they don't end with '. How would I capture that with this?
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, June 30, 2007, 10:48 -->
<!-- MuClient version 4.13 -->
<!-- Plugin "Chat_Redirector" generated by Plugin Wizard -->
<!--
Edit plugin and change "chat_world" variable to be the name of the
world you want chats to go to.
-->
<muclient>
<plugin
name="Chat_Redirector"
author="Nick Gammon"
id="cb84a526b476f69f403517da"
language="Lua"
purpose="Redirects chat messages to another world"
date_written="2007-06-30 10:45:35"
requires="4.08"
version="2.0"
>
<description trim="y">
<![CDATA[
Redirects chats to the specified world.
Add or modify "chat" triggers to capture different sorts of message.
Change the variable "chat_world" to be the name of the world chats are to go to.
]]>
</description>
</plugin>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
match="^(\(.+\): )?[A-Za-z +]+ (CHATS|GOSSIPS|GRATZS|WIZS|QUESTCHATS|INFOS|IMCCHATS|AUCTIONS|WIZINFOS|CLANTALKS) '"
regexp="y"
script="chat_redirect"
omit_from_output="y"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="^[(CHAT|GOSSIP|GRATZ|WIZ|QUESTCHAT|INFO|IMCCHAT|AUCTION|WIZINFO|CLANTALK)] "
regexp="y"
script="chat_redirect"
omit_from_output="y"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="^You (CHAT|GOSSIP|GRATZ|WIZ|QUESTCHAT|INFO|IMCCHAT|AUCTION|WIZINFO|CLANTALK) '"
regexp="y"
script="chat_redirect"
omit_from_output="y"
sequence="100"
>
</trigger>
<trigger
enabled="n"
match="*"
omit_from_output="y"
script="chat_redirect"
name="multi_line_chat"
sequence="10"
>
</trigger>
<trigger
enabled="n"
match="*"
omit_from_output="y"
script="chat_redirect"
name="prompt"
sequence="10"
>
</trigger>
</triggers>
<!-- Script -->
<script>
<![CDATA[
chat_world = "Chat"
who_world = "Who List"
require "getworld" -- handles finding the world, and sending the line
-- chat redirector
function chat_redirect (name, line, wildcards, styles)
send_to_world (chat_world, styles)
-- 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 chat_redirect
]]>
</script>
</muclient>
Example:
[CHAT] Blackjack just wants things to work as close to perfectly as possible,
is that really too much to ask
It will catch it, but it will also catch the newline after it, or even both the newline and the prompt, which I don't want cluttering up the place. Any advice?
You need to identify what is different about the line that is not the chat line, so it can stop when it hits it. Perhaps post an example chat with an example of what follows it?
I've been using this script, albeit highly modified, for quite some time now. I've come to a scenario where I want to send my information messages (info messages from the client, not from the M* I'm connected to) to a separate window.
Is this possible with the current script? If not, is there anything I can use to do such?
It could probably be done one way or another. You could intercept "Note" function calls and make them do something else, if that is where the notes are coming from.
This is a great plugin and all, and I use it quite successfully on the Discworld MUD.. However, how can I put this exact same redirect script into a mini window with a context menu to choose which channels/chats to echo in the main output (like the Aardwolf chat window), instead of a world window?
Quote: This is a great plugin and all, and I use it quite successfully on the Discworld MUD.. However, how can I put this exact same redirect script into a mini window with a context menu to choose which channels/chats to echo in the main output (like the Aardwolf chat window), instead of a world window?
If you want features from plugins written for the Aardwolf client package, copy from the plugin source files. They're not exactly hidden.
Hi guys,
I'm struggling with a script that is related to this. Basically what i want to do is to capture the chats but not send it to another window. Instead i want an alias to print a stored set of say 10 or 15 chats to the main world. Honestly i'm not even sure how to start, but it looks related to this topic at least so thought id start here.
Any help would be appreciated, not necesarrily in the form of written code, but any references, links, a push in the right direction etc would be welcome.
Thanks!
Tom
Basically all data in the output window (output buffer) is organized into style runs, where one run consists of one or more characters with the same colour, boldness, italicness, etc.
So to copy the colours from one window to another (or a miniwindow) you need to take into account the colours returned by that portion of a style run.