How to make a separate chats window

Posted by Nick Gammon on Sat 30 Jun 2007 01:24 AM — 112 posts, 535,253 views.

Australia Forum Administrator #0
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>

Amended on Sat 30 Jun 2007 01:26 AM by Nick Gammon
#1
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.
USA #2
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.
USA #3
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 :)

-Onoitsu2
USA #4
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.
USA #5
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.

-Onoitsu2
#6
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."

Thank you for your time and help
Australia Forum Administrator #7
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:


<!--  Triggers  -->

<triggers>

  <trigger
   enabled="y"
   match="^(\(.+\): )?[A-Za-z]+ (says|yells|tells you), &quot;.+&quot;$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

  <trigger
   enabled="y"
   match="^You (tell|whisper) .+, &quot;.+&quot;$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

</triggers>


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.
#8
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 -

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4313

Sub OnChat (name, line, wildcards)
Dim msg

msg = Split (wildcards (10), chr (10))

For Each m In msg
AppendToNotepad "Chats", m & vbCrLf
Next

end Sub


<triggers>
<trigger
enabled="y"
lines_to_match="10"
match="^\(Serpentlords\): (.*?) &quot;([^&quot;]+)&quot;\Z"
multi_line="y"
name="chats"
regexp="y"
script="OnChat"
sequence="100"
>
</trigger>
</triggers>

Thanks again so much for your help

PS: I assume triggers won't work in an offline world?

Amended on Wed 27 Feb 2008 12:52 AM by Aromaros
Australia Forum Administrator #9
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), &quot;.+"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

  <trigger
   enabled="y"
   match="^You (tell|whisper) .+, &quot;.+"
   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 seems to work OK for me. :)
Amended on Wed 27 Feb 2008 01:13 AM by Nick Gammon
#10
You are amazing Nick, absolutely amazing. The plugin and scripts work perfectly now. Thanks for everything!
Australia Forum Administrator #11
You are welcome. :)

Quote:

PS: I assume triggers won't work in an offline world?


Well they won't work in the sense that if you are offline you won't receive anything.

However I usually test by using the "Debug simulated world input" menu item (Shift+Ctrl+F12). See:

http://www.gammon.com.au/scripts/doc.php?dialog=IDD_DEBUG_INPUT

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.
Amended on Wed 27 Feb 2008 07:24 AM by Nick Gammon
#12
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.

Any ideas?
Amended on Mon 03 Mar 2008 11:22 PM by Aromaros
Australia Forum Administrator #13
Your who list seems to end with a blank line, can't you test for that?
#14
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.
Amended on Tue 04 Mar 2008 02:27 PM by Aromaros
Australia Forum Administrator #15
Ah, that one is easier to read. ;)

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.
#16
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?

function redirect (name, line, wildcards, styles)
Amended on Tue 04 Mar 2008 07:20 PM by Aromaros
Australia Forum Administrator #17
Quote:

-- 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 
Australia Forum Administrator #18
Version 4.23, just released, no longer will display "[Closed]" in the title of your extra (dummy) worlds.
#19
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:

<triggers>
<trigger
enabled="y"
match="^\(OOC\)*"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>

Ideas?
Australia Forum Administrator #20
Quote:

match="^\(OOC\)*"


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="&lt;*hp *m *mv&gt; &lt;#*&gt;*"
   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.

Australia Forum Administrator #21
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), &quot;.+"
   regexp="y"
   script="chat_redirect"
   omit_from_output="y"
   sequence="100"
  >
  </trigger>

  <trigger
   enabled="y"
   match="^You (tell|whisper) .+, &quot;.+"
   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>


#22
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.
#23
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.
Australia Forum Administrator #24
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.
Australia Forum Administrator #25
Quote:

At some points in the game the plugin will catch some text that confuses it, something with a few quotations in it I believe.


Again, if this happens often, capture the whole lot around where it happens and post it (x-out names if you like), so we can analyze it.

However the way the plugin works, redirecting is turned on with a fairly specific trigger, it shouldn't just turn on when it hits a quote.
#26
Thanks for the response. Here is an extended log from the MUD.

Quote:
(OOC) Orion: Hoy.
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night

(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

ooc great, thanks
(OOC) Koreabard: great, thanks
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night


  • All chats start with the string '(OOC)'
  • 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.


Australia Forum Administrator #27
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.
#28
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).

Australia Forum Administrator #29
Well that is not really the chat plugin's fault. I think what is happening is this. You get:


H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night
(OOC) Orion: Hoy.
(OOC) Namino blinks.
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night
(OOC) Koreabard: great, thanks
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night


You have successfully moved the chats to another window, leaving you with:


H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night


This is nothing to do with a blank CRLF - it is simply what is left once you move the chats.

I suggest you adapt the trigger I gave earlier, which simply suppresses multiple prompts, if they are identical to the previous one.
#30
OK, I will try the suppression idea.

However, the sequence is not quite as you listed. I do not get the status line unless (1) I manually hit Enter key, or (2) I get a chat line.

Quote:
(OOC) Orion: Hoy.
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night

(OOC) Namino blinks.
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night

(OOC) Koreabard: great, thanks
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night


Basically, the Chat line seems to end with a newline, which gets processed by MUSHclient and sent back to the MUD, which then echoes the status line.

Thus, it seems that the suppression of output to the main client window is not complete -- the newline character is allowed.
Amended on Sat 07 Jun 2008 12:55 AM by Zylogia
Australia Forum Administrator #31
There is nothing in that first plugin that sends anything back to the MUD.

You said you get the status line after a chat line, and the problem occurs after a chat line appears.
#32
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.
Australia Forum Administrator #33
Based on your previous example:


(OOC) Orion: Hoy.\n
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night\n
\n
(OOC) Namino blinks.\n
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night\n
\n
(OOC) Koreabard: great, thanks\n
H:Healthy, S:Energetic, K:Energetic, F: 100, Camday night\n


I have added the newlines to show the idea. I assume you are just sitting there, and some chats come in.

Your trigger moves the chat to the other window, but, per chat line, you are left with two other lines - one blank, and one status.

One approach to get rid of the blank lines is to make another trigger, like this:


<triggers>
  <trigger
   enabled="y"
   match="^$"
   omit_from_output="y"
   regexp="y"
   sequence="100"
  >
  </trigger>
</triggers>


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".

Australia Forum Administrator #34
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), &quot;.+"
   regexp="y"
   script="chat_redirect"
   omit_from_output="y"
   sequence="100"
  >
  </trigger>

  <trigger
   enabled="y"
   match="^You (tell|whisper) .+, &quot;.+"
   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>
Amended on Fri 20 Jun 2008 05:48 AM by Nick Gammon
USA #35
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'
Australia Forum Administrator #36
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
Amended on Tue 29 Jul 2008 09:17 PM by Nick Gammon
USA #37
yeah, i know enough to know where i needed to change stuff, but not enough to know what to add/change :P and it works great now.

Thanks
#38
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.


<triggers>
<trigger
enabled="y"
match="^.+ pages\: .+$"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
<send>%0</send>
</trigger>
<trigger
enabled="y"
match="^\[.+\] .+$"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
<send>%0</send>
</trigger>
<trigger
enabled="y"
match="^From afar, .+$"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
<send>%0</send>
</trigger>
<trigger
enabled="y"
match="^Long distance to .+$"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
<send>%0</send>
</trigger>
<trigger
enabled="y"
match="^You paged .+$"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
<send>%0</send>
</trigger>


</triggers>
Australia Forum Administrator #39
Remove the %0 from the "send" box. What you are doing is echoing back the chat to the MUD, so for example if you get:


From afar, Nick smiles


Your trigger sends back to the MUD:


From afar, Nick smiles


So naturally it replies "huh?".
#40
I removed the <send>%0</send> from the triggers, but it still does it. :/
Amended on Fri 17 Oct 2008 12:44 AM by Zeyomie
Australia Forum Administrator #41
Well can you copy the whole plugin and paste it into the forum here? It should fit.
#42
I have it disabled at the moment. but here is the plugin.

<?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="^.+ pages\: .+$"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="^\[.+\] .+$"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="^From afar, .+$"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="^Long distance to .+$"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="^You paged .+$"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>


</triggers>

<!-- Script -->


<script>
<![CDATA[
chat_world = "Rell Chat"
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>
Australia Forum Administrator #43
OK, thanks - and now can you copy and paste an example of the output that causes it? (eg. From afar, Nick sighs).

That way I know which trigger is being used.
Australia Forum Administrator #44
When you changed the plugin, did you reinstall it? Simply changing the file won't do anything while it is loaded in memory. In the plugin list, click the Reinstall button to do that.
#45
What exactly does this bit of code do?

for _, v in ipairs (styles) do
w:ColourTell (RGBColourToName (v.textcolour),
RGBColourToName (v.backcolour),
v.text)
end -- for each style run

What does the _ mean exactly, and where did the styles parameter come from? Can this script handle the fact that there is possibly more than one color in a say/tell/yell?

Ultimately, I want to convert this to python (since I have way to many scripts in python already), but I'm trying to get the colors, and I really don't see how to do that...

sleeper
Australia Forum Administrator #46
In Lua, a variable name can be _, and by convention, the variable named _ is a variable you aren't too interested in the value of (eg. think of it as _temp).

The styles parameter is passed as the 4th argument to a trigger, in Lua only. The COM definition for the trigger handler in other languages is for 3 arguments, so that can't be changed. For other languages you could use GetStyleInfo to find out the style runs in a line (you also need to work out which line it is). This has been covered a bit on the forum, search for GetStyleInfo.

http://www.gammon.com.au/scripts/doc.php?function=GetStyleInfo

Yes, the script is designed to handle multiple styles. That for loop iterates through the table of styles.
#47
I'm bummed the styles is only a lua parameter. Would be really convenient to have it in python. :)

That explanation makes perfect sense. Thanks for the answer.

sleeper
#48
STOP! I have an idea! It just might work! Use the MUSHCLIENT notepad instead of using complicated scripts and plugins!

Set up an alias: called SETMINIWINDOWS

AppendToNotepad("CHAT","Start:")
MoveNotepadWindow("CHAT",826,1,200,720) -- resizing notepad
NotepadFont("CHAT","Bitstream Vera Sans Mono",10,1,0)
NotepadColour("CHAT","whitesmoke","black")
MoveWorldWindow(0,0,825,723) -- resizing mud window

-------------------------------------------------------

Type: SETMINIWINDOWS, ta-da there is the main world + a notepad window.


Use triggers to catch <whatever> then use
AppendToNotepad("CHAT","<whatever>")

:-D
[Go to top]
#49
Okay I am 100% new to scripting. I only recently have learned how to even add plugins. My problem is I am trying to incorporate this but languages are in my mud along with unique ooc tags for ooc channels and each clan channel as a specific adjective for the tag.

You moodily say 'test'
You moodily say, in Arkanian 'test'
(NEWBIE) *Anastasius: test
CommNet 0 [Soal]( moodily )<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.
#50
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>


Matches: [- AdasCorp -]{Arkanian Engineering}<Junior Technician>[Soal]( moodily )<Arkanian>: test

<trigger
   enabled="y"
   match="[- AdasCorp -]{*}<*>[*]( * )<*>: *"
   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>

or
Matches: CommNet 0 [Soal]( moodily )<Arkanian>: Hrm
       : CommNet 1 [Soal]: hrm

<trigger
   enabled="y"
   match="CommNet *"
   regexp="n"
   script="redirect"
   sequence="100"
  >
</trigger>

Amended on Tue 10 Nov 2009 01:46 AM by Blainer
#51
All the triggers above should work in the plugin if you have them between the <triggers> and </triggers> tags.

You could read/watch these too. The videos are great.
Template:post=9626
Please see the forum thread: http://gammon.com.au/forum/?id=9626.

Template:post=9616
Please see the forum thread: http://gammon.com.au/forum/?id=9616.

Template:post=9617
Please see the forum thread: http://gammon.com.au/forum/?id=9617.

Template:regexp
Regular expressions
  • Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
  • Also see how Lua string matching patterns work, as documented on the Lua string.find page.
Amended on Tue 10 Nov 2009 01:49 AM by Blainer
#52
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.
#53
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?
Australia Forum Administrator #54
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.

Template:saveplugin=Omit_Blank_Lines
To save and install the Omit_Blank_Lines plugin do this:
  1. Copy the code below (in the code box) to the Clipboard
  2. Open a text editor (such as Notepad) and paste the plugin code into it
  3. 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.
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file Omit_Blank_Lines.xml (which you just saved in step 3) as a plugin
  7. Click "Close"
  8. Save your world file, so that the plugin loads next time you open it.



<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, July 07, 2008, 1:07 PM -->
<!-- MuClient version 4.31 -->

<!-- Plugin "Omit_Blank_Lines" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Omit_Blank_Lines"
   author="Nick Gammon"
   id="87a0ec3649ab9a04d5ea618d"
   language="Lua"
   purpose="Omits blank lines from output"
   date_written="2008-07-07 13:06:47"
   requires="4.00"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Omits completely empty lines from output.
]]>
</description>

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   match="^$"
   omit_from_output="y"
   regexp="y"
   sequence="100"
  >
  </trigger>
</triggers>

</muclient>

#55
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.
Australia Forum Administrator #56
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.
#57
That did it. Updated my version, and it's working, all nifty-like. Thanks!
#58
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.
Amended on Wed 23 Dec 2009 04:19 PM by Lawlimnatorization
Australia Forum Administrator #59
Check this out:

Template:post=7991
Please see the forum thread: http://gammon.com.au/forum/?id=7991.


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.
#60
>.>

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.
Australia Forum Administrator #61
Oh yeah, I thought it looked familiar. :P

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?
Amended on Thu 24 Dec 2009 07:42 AM by Nick Gammon
Canada #62
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.
Amended on Mon 25 Jan 2010 08:51 PM by Cerxi
#63
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.
Australia Forum Administrator #64
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.
#65
I've toying with it here n there, found out the says are working in town and guild chats such as this:

(Sar-Sargoth): Raki says, "Thank you everyone for the hunt."
(Sar-Sargoth): Dhaed says, "Yes, thank you very much for the hunt."

But nothing I say in any kind of chat goes to the chat window, everything stays in in the main window:

(Clan Raven): You say, "Mhm."

You say in Moredhel, "Uhh."

(Sar-Sargoth): You say, "K."


And heres the plug in as it is loaded into 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="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), &quot;.+"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>

<trigger
enabled="y"
match="^You (say|tell|whisper) .+, &quot;.+"
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>
Netherlands #66
Try:

<trigger
enabled="y"
match="^(\(.+\): )?[A-Za-z]+ (says|yells|tells you), &quot;.+"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>

<trigger
enabled="y"
match="^(\(.+\): )?You (say|tell|whisper)(?: .+)?, &quot;.+"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>


Should fix your issues. I don't think I changed the first trigger, but just to make sure I kept both in my post. :)
#67
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








Amended on Thu 11 Feb 2010 07:30 PM by Basyiel
#68
Okay, somethings are carrying over, and some are not.


You say 'bah'

is carrying over, while

[OOC] Valasha says 'test'

[OOC] Volkar says 'but I did not study I hope its open book'

are not.

Any suggestions on how to make these work?
#69
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.

<trigger
enabled="y"
match="'*'"
regexp="n"
script="chat_redirect"
omit_from_output="n"
sequence="100"
>
</trigger>

Thanks for your help.
Amended on Tue 25 Jan 2011 09:21 AM by Slowreflex
Australia Forum Administrator #70
Modifying your trigger slightly to colour the line but not call a script gives this:



<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="'*'"
   sequence="100"
  >
  </trigger>
</triggers>


That does not match this line:


[OOC] Volkar says 'but I did not study I hope its open book'


Nor would I expect it to, as the line doesn't start with a quote.

I doubt you actually copied the trigger as advised here:

Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


If you did, it wouldn't have this in it:


regexp="n"


That is because not being a regexp is the default, and it doesn't normally put defaults in.

So to assist you, I need the actual trigger you say doesn't work, not a modified version.
#71
Hi Nick, you answered Verdilak, but not me. Did you miss my post?
Australia Forum Administrator #72
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?

Template:copying
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.
#73
Nick, I used the trigger/script as listed from the first post on this thread.
Australia Forum Administrator #74
So this trigger?


  <trigger
   enabled="y"
   match="^[A-Za-z]+ (says|chats|yells) \'(.*?)\'$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>


That won't match on lines starting with "[OOC] " so you need to add that as an option:


  <trigger
   enabled="y"
   match="^(\[OOC\] )?[A-Za-z]+ (says|chats|yells) \'(.*?)\'$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>


The question mark means that "[OOC] " is an optional prefix.
#75
Slowreflex said:

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.

<trigger
enabled="y"
match="'*'"
regexp="n"
script="chat_redirect"
omit_from_output="n"
sequence="100"
>
</trigger>

Thanks for your help.



Nick, my trigger was in my original post. Hope you can help. Thanks.

JT
Australia Forum Administrator #76
Can you humour me please by copying it again as described here?

Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


For one thing, I should see:


<triggers>

Amended on Wed 26 Jan 2011 10:06 PM by Nick Gammon
#77
I've had a tinker around with no success, how can I get it to play a sound every time something is written to the chat window/world?

I'd assume I add something like:

PlaySound (0, "sound.wav")

Somewhere in the script.

My current script is too long to quote here so I've popped it on pastbin http://pastebin.com/4g7DsSXy

Any help would be very much appreciated.

~Sinule

#78
I'm having problems getting this script to work exactly the way I'd like it to and for the life of me I cannot get it right.

This is what I'm using right now.

<triggers>

<trigger
enabled="y"
match="'*'"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>

<trigger
enabled="y"
match="'*'"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>


</triggers>

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?'

The last example is a tell.

Any help?
Amended on Sat 14 May 2011 06:08 PM by TheExile
USA Global Moderator #79
Why do you have two identical triggers with the same wrong pattern?

"'*'" is not valid regex for capturing between apostrophes.
"'.*'" might be.
Amended on Sat 14 May 2011 11:11 PM by Fiendish
#80
Grrr.. my mistake I had problems copying my script and had to edit my post acouple times.

In any case, yes thank you, that fixed my problem.
#81
I'm trying to pick up something like "<COMLINK: Oedal> test" from the chat window. How would i format my trigger to pick that up?
#82
I'm using the original plug-in with Achaea. Works great, but now I get lots of extra prompt lines in my main window.

Is there an easy way to make this omit the prompt from after only the lines that are redirected?
#83
Hello, this is my first post here.
I'm trying to get this plugin to work I'm replacing the line:
match="^[A-Za-z]+ (says|chats|yells) \'(.*?)\'$"

with

match="(<page>|<public>|<debate>|<OOC>)*"

When I install it and run it it says the following error message after opening the second window:

Can't open chat world file: C:\Program Files\MUs\MUSHClient\worlds\RoD chats.mcl

Is there anything I've done wrong? I entered "0.0.0.0" for the TCP/IP address like suggested. The Port is set to 4000 for some reason though.
Australia Forum Administrator #84
Is there such a file?
#85
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,
Amended on Fri 24 Feb 2012 02:23 AM by Ashleykitsune
#86
Alright, that's what it was. Everything works fine now! So that's one goal on my profile that I can check off, now to move on to the next one.
#87
I'm trying to get all messages starting with:

On your wristpad radio:
and
[zotnet]

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...
#88
If needed, better examples:

[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!
#89
FruitSmoothie said:

If needed, better examples:

[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.
#90
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?

Thanks
Australia Forum Administrator #91

  if line:sub (-1) == '==============================================================================' then


Testing this:


line = "=============================================================================="
print (line:sub(-1))


This prints "=".

You are comparing the last character of the line to a whole lot of equals signs, which won't match.

Maybe:


  if line == '==============================================================================' then

#92
Perfect. That fixed it!
#93
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?
#94
Hi, I'm trying(And failing) to adapt this to a MUCK I play on. Sadly, I can't get anything to show up on the "Chat World"

The standard channels are;

<OOC> <name> says
<OOC> <name> <does something>
[Public] <name> says
[Public] <name> <does something>
says
page

If anyone can help, it'd be greatly appreciated :)


EDIT: With exception to the <OOC> itself, the things in <> are variables, just in case it isn't clear :P
Amended on Sun 17 Mar 2013 04:25 PM by Alkain
Australia Forum Administrator #95
@Squeegy - sorry, I missed this question.

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?




@Alkain - can you post what you tried?
#96
Nick Gammon said:


@Alkain - can you post what you tried?



Sadly I erased it all, but I tried several of the fixes listed here with slight modifications.

I did set up the chat world as specified and made sure the script pointed to it.

I just fiddled with the match= line though, but I can't remember what I did exactly :/
Australia Forum Administrator #97
I think there are a few versions over the life of this thread. Take then one you tried, try to get it working, and then post what you have.
#98
I would, but I really have no idea what I'm doing. I'm new to Mushclient and have no coding experience :/
#99
Soooo, it's been a while... Any help would be appreciated, I'm also looking for how to make a clock or something similar.


EDIT: Thanks to a friend, I was able to get it working. THanks for the help though
Amended on Thu 28 Mar 2013 09:23 AM by Alkain
#100
Hello!

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?

I'd appreciate it if anyone could help!
#101
I suppose I used the wrong term. Rather than information, I suppose notes would be the proper term. Sorry for the confusion, if any.
Australia Forum Administrator #102
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.
USA Global Moderator #103
I use the CallPlugin interface.
#104
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?
USA Global Moderator #105
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.

There are also (somewhat old) threads here:
http://www.gammon.com.au/forum/bbshowpost.php?id=10728&page=1
and here:
http://www.gammon.com.au/forum/?id=10143

Broken links to my repository found in those threads are probably corrected later in the threads, so keep reading if you hit a dead link.
#106
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
Australia Forum Administrator #107
Start a new thread, I suggest. Reference this one if you like, but this is really a different topic.
#108
What is the "styles" variable that you are iterating through? I've seen it in several places/scripts but never explained.
Amended on Fri 09 May 2014 09:29 PM by Deramius
Australia Forum Administrator #109
See here for some explanation:

http://www.gammon.com.au/scripts/doc.php?dialog=IDD_EDIT_TRIGGER

(This is available under the edit triggers help).

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.
#110
Are you required to include the "Styles" parameter in the formal parameters of a function or is it optional?

If it's optional, are there are other parameters that are optional?
Australia Forum Administrator #111
In Lua it is optional. There are no other optional arguments.