Posted by
| Nick Gammon
Australia (23,102 posts) Bio
Forum Administrator |
Message
| 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:
<trigger
enabled="y"
match="^[A-Za-z]+ (says|chats|yells) \'(.*?)\'$"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>
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>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|