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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Tips and tricks
. . -> [Subject]  How to make a separate chats window

How to make a separate chats window

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


Pages: 1 2  3  4  5  6  7  8  

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Sat 30 Jun 2007 01:24 AM (UTC)

Amended on Sat 30 Jun 2007 01:26 AM (UTC) by Nick Gammon

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

Posted by Incense   (1 post)  [Biography] bio
Date Reply #1 on Thu 31 Jan 2008 11:07 AM (UTC)
Message
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.
[Go to top] top

Posted by Shaun Biggs   USA  (644 posts)  [Biography] bio
Date Reply #2 on Thu 31 Jan 2008 03:43 PM (UTC)
Message
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.

It is much easier to fight for one's ideals than to live up to them.
[Go to top] top

Posted by Onoitsu2   USA  (248 posts)  [Biography] bio
Date Reply #3 on Fri 01 Feb 2008 05:22 AM (UTC)
Message
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
[Go to top] top

Posted by Shaun Biggs   USA  (644 posts)  [Biography] bio
Date Reply #4 on Fri 01 Feb 2008 03:48 PM (UTC)
Message
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.

It is much easier to fight for one's ideals than to live up to them.
[Go to top] top

Posted by Onoitsu2   USA  (248 posts)  [Biography] bio
Date Reply #5 on Sat 02 Feb 2008 12:45 AM (UTC)
Message
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
[Go to top] top

Posted by Aromaros   (9 posts)  [Biography] bio
Date Reply #6 on Tue 26 Feb 2008 12:30 AM (UTC)
Message
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
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Tue 26 Feb 2008 04:45 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Aromaros   (9 posts)  [Biography] bio
Date Reply #8 on Wed 27 Feb 2008 12:21 AM (UTC)

Amended on Wed 27 Feb 2008 12:52 AM (UTC) by Aromaros

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

[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Wed 27 Feb 2008 01:12 AM (UTC)

Amended on Wed 27 Feb 2008 01:13 AM (UTC) by Nick Gammon

Message
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. :)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Aromaros   (9 posts)  [Biography] bio
Date Reply #10 on Wed 27 Feb 2008 01:22 AM (UTC)
Message
You are amazing Nick, absolutely amazing. The plugin and scripts work perfectly now. Thanks for everything!
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #11 on Wed 27 Feb 2008 04:54 AM (UTC)

Amended on Wed 27 Feb 2008 07:24 AM (UTC) by Nick Gammon

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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Aromaros   (9 posts)  [Biography] bio
Date Reply #12 on Mon 03 Mar 2008 10:47 PM (UTC)

Amended on Mon 03 Mar 2008 11:22 PM (UTC) by Aromaros

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

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #13 on Tue 04 Mar 2008 04:21 AM (UTC)
Message
Your who list seems to end with a blank line, can't you test for that?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Aromaros   (9 posts)  [Biography] bio
Date Reply #14 on Tue 04 Mar 2008 05:03 AM (UTC)

Amended on Tue 04 Mar 2008 02:27 PM (UTC) by Aromaros

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

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

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


364,376 views.

This is page 1, subject is 8 pages long: 1 2  3  4  5  6  7  8  [Next page]

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

Go to topic:           Search the forum


[Go to top] top

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

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

[Home]


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

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

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