Register forum user name Search FAQ

Gammon Forum

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

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

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Multiple Chat Capture Miniwindow

Multiple Chat Capture Miniwindow

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


Posted by Xinefus   (106 posts)  Bio
Date Thu 23 Apr 2020 07:39 PM (UTC)

Amended on Thu 23 Apr 2020 07:56 PM (UTC) by Xinefus

Message
Hello everyone, I am a long time snooper and first time joining the conversation.

I have been using MUSHclient for a number of years, playing SMAUG based MUDs.

I recently decided to try and spice up my visual experience and try my hand at some plugins to parse different elements of my MUD to miniwindows. I really enjoy the concept but my limited knowledge in lua hinders my progress.

I have been able to successfully implement a Chat Capture Miniwindow such as outlined in Post #5 of:

http://www.gammon.com.au/forum/bbshowpost.php?id=10728&page=1

I would however like to have multiple of these same style miniwindows, each for different chatter that happens in the MUD, such as one for tells and one for ooc?

I have so far been able to put them all in one miniwindow, but I don't know how to create a new window so that I can send different items to it.

Your help with this would be greatly appreciated.

Thanks a bunch.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 23 Apr 2020 08:53 PM (UTC)
Message
The mapper window name is based on the plugin ID, so what you could do is make multiple plugins (all with a different ID) near the start:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
    <plugin
    name="Chat_Capture_Miniwindow"
    author="Fiendish"
    id="565dae21eb816a2fdb8d50f9"    <---------- PLUGIN ID
    language="Lua"
...


Use MUSHclient's Edit menu -> Generate Unique ID to make yourself new plugin IDs.

Now replace the triggers with ones that match the particular text you want to be in the chat window.

To save duplicating all the code, pull out the code part (between <script> and </script>) and put into a separate file (in the same folder as the plugins). Then include it like this:


<!--  Script  -->

<script>
    dofile (GetPluginInfo (GetPluginID (), 20) .. "My_Chat_Window.lua")
</script>


You can add extra lines at the start as required (for example, the chat window name), eg.


<!--  Script  -->

<script>

    CHAT_WINDOW_NAME = "Tells"

    dofile (GetPluginInfo (GetPluginID (), 20) .. "My_Chat_Window.lua")
</script>


Now further down in the code (in the file you just made) find the lines:


    -- Title text
    WindowText(Win, "titlefont"..Win, "COMMUNICATION", ...


And change the fixed word "COMMUNICATION" to be the variable above, eg.


    -- Title text
    WindowText(Win, "titlefont"..Win, CHAT_WINDOW_NAME, ...


Notice the absence of quotes as this is a variable, not a literal.

Now each window will have a different title.

Then install each of the plugins you made.

- Nick Gammon

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

Posted by Xinefus   (106 posts)  Bio
Date Reply #2 on Thu 23 Apr 2020 09:14 PM (UTC)
Message
Oh my! What a speedy and thorough response!

This worked fantastically!

Thank you so much for the help and push in the right direction.

I'll be working on other little tidbits as I go, maybe you will see me on here again.


Cheers!
Top

Posted by Xinefus   (106 posts)  Bio
Date Reply #3 on Thu 14 May 2020 07:40 PM (UTC)

Amended on Thu 14 May 2020 07:57 PM (UTC) by Xinefus

Message
I've been able to make this work and I really love it.

Is there a way to have 1 plugin do multiple chat miniwindows?

lets say I want a few of the triggers to go in one window and other triggers to go in another?

Right now, each plugin sends the triggers to the 'chats' script. How would I go about changing this so within the same plugin there could be 2 or 3 diff windows.. Is this something that is possible?

Refs: A. https://github.com/DBNU-Braska/DBNU/blob/master/Chat_Capture_Miniwindow.xml
B. https://github.com/DBNU-Braska/DBNU/blob/master/My_Chat_Window.lua
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #4 on Fri 15 May 2020 05:36 AM (UTC)
Message
Almost anything is possible. This will probably be a bit more work for you. :)

In most plugins which show one window there is a global variable for the window name (usually win or Win but it could be anything). For example from that plugin:


    WindowShow( Win, false )


Now if you want to have multiple windows you would need to assign different names for the different windows, for example instead of:


Win = GetPluginID()


You might have:


Group_Win  = GetPluginID() .. "_group"
Newbie_Win = GetPluginID() .. "_newbie"
Clan_Win   = GetPluginID() .. "_clan"


Now the stuff that creates windows etc. would have to be done for each one. The easy thing would be to keep using Win in most of the code, and in the trigger for each chat type switch the contents of that variable, like this:


-- inside the trigger

Win = Group_Win  -- this stuff goes into the Group window

-- do usual stuff here


You would also have to switch around the buffer which holds the lines. Again, this could be done by making various tables (rawlines in the plugin I am looking at) and then switch the table appropriately. In Lua tables are stored by reference, so this would be fast.

So yes, it could be done.

- Nick Gammon

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

Posted by Xinefus   (106 posts)  Bio
Date Reply #5 on Fri 15 May 2020 07:24 PM (UTC)
Message
Alright, so before I jump into this (which you do say it is possible!), here is what I understand, and a bit that I don't.

Let's go with your example of Group, Newbie, Clan all in one plugin.

For this to work, I assign additional window names just as you mention; this is in my "My_Chat_Window.lua". From the trigger portion within my plugin, Do I just add the new line within the trigger:

	<trigger
   enabled="y"
   match="<(OOC|IMM)> {(.+)} \((.+)\) ([a-zA-Z]+) \'(.*?)\'$"
   omit_from_output="y"
   regexp="y"
   script="chats"
   Win = Group_Win  -- this stuff goes into the Group window
   sequence="100"
  >
  </trigger>


Or does that line go in the script portion? Do I have to create functions (group_chats, newbie_chats, clan_chats) within scripts that send the info to "My_Chat_Window.lua" while defining the Win along with the window name?

Right now I am using "My_Chat_Window.lua" to create multiple miniwindows with separate plugins. These use the same tables? I'm a bit confused how I can be using the same .lua but they are different tables.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #6 on Fri 15 May 2020 08:57 PM (UTC)
Message
Not exactly. You can't put script stuff inside the XML part of the trigger.

Instead of:


script="chats"


You could have what you suggest, eg.


script="group_chats"


OK, so now you need a group_chats function. So that could look like this:


function group_chats (name, line, wildcards, styles)
  Win = Group_Win  -- switch to the Group window name
  chats (name, line, wildcards, styles) -- call the usual function
end -- group_chats


You are basically redirecting the trigger to a function that does one more thing before calling the usual one.

You also need new tables for the lines, so instead of:


-- where to store the chat line
lines = {}  -- table of recent chat lines
rawlines = {}



You could have:


-- where to store the chat line
Group_lines = {}  -- table of recent group chat lines
Group_rawlines = {}
Clan_lines = {}  -- table of recent clan chat lines
Clan_rawlines = {}
Newbie_lines = {}  -- table of recent newbie chat lines
Newbie_rawlines = {}


So now the function above also "switches" to those tables:


function group_chats (name, line, wildcards, styles)
  Win = Group_Win  -- switch to the Group window name
  lines = Group_lines  -- and the group lines
  rawlines = Group_rawlines  -- and the group rawlines
  chats (name, line, wildcards, styles) -- call the usual function
end -- group_chats


There may be other variables around that need switching around but that is the basic idea.

- Nick Gammon

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

Posted by Xinefus   (106 posts)  Bio
Date Reply #7 on Fri 15 May 2020 11:11 PM (UTC)
Message
Thanks for the boost. I am not comfortable enough to be doing such a complicated thing in lua. I don't understand enough of how the relationships work within the miniwindow.

I tried to understand the

GetPluginID() .. "_group"

But I can't figure out what Win parts I should and should not have to change within the plugin.

In function init(firstTime), would I have to duplicate each of the statements one for each Group_Win and Clan_Win? or is the 'switch' doing that already for me?

For the tables:

if (firstTime == true) then
        Group_lines = {}
        Clan_lines = {}
        for _,styles in ipairs(Group_rawlines, Clan_rawlines) do 
            fillBuffer(styles)
        end  -- for each line


Is the tables part right?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #8 on Sat 16 May 2020 05:49 AM (UTC)
Message

No, sorry.

I tried to do it myself, and realize now that the plugin was designed with one window in mind, and lots of it (like the table of lines, the resizing, all sorts of things) follow from that design decision.

To rework it would take a long time (especially as Fiendish modified my original code, so I’m not totally familiar with it).

I don’t think the effort involved justifies the time, considering that the multiple plugins idea works fine for you.

To be clear, it could be done — almost anything is possible, but the effort involved would be considerable, and if you are not familiar with Lua you would need to spend quite a bit of time learning that first.


- Nick Gammon

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

Posted by Xinefus   (106 posts)  Bio
Date Reply #9 on Sat 16 May 2020 09:16 AM (UTC)
Message
Not a problem! I will keep it as is then and create a couple of plugins to do just what I am looking to do.
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.


25,079 views.

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

Go to topic:           Search the forum


[Go to top] top

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