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.
 Entire forum ➜ MUSHclient ➜ Suggestions ➜ Chat prefixes

Chat prefixes

Posting of new messages is disabled at present.

Refresh page


Posted by Norbert   USA  (61 posts)  Bio
Date Fri 19 May 2006 03:31 PM (UTC)
Message
I was wondering if a script function could be added to allow the Chat prefixes to be changed. I know the one in the world configuration is there, which I use that one. It's the one that is generated immediately after that one that I want to change. For example:

my chat prefix is [C] and I currently see

[C]You chat to Player, 'message'
[C]Player chats to you, 'message'
[C]You emote to Player: Me nods.

What I'd like to see is

[C]Me says: 'message'
[C]Player says: 'message'
[C]Me nods.
[C]Player nods.

Or if there is already a way to adjust these with current script functions please let me know.

Norbert

-Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens
It's a dumb question... skip it.
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 19 May 2006 10:41 PM (UTC)
Message
Yes, the chat system was designed to be fully scriptable. To do this you need to modify the chat plugin. I have modified the Lua chat plugin because I prefer Lua these days. The functionality is the same as the VBscript one. It is at:

http://www.gammon.com.au/mushclient/plugins/Lua_Chat.xml


Edit the plugin in an editor, and search for the function OnPluginChatDisplay. This is called when MUSHclient is about to display a chat message. What we do is detect the normal chat message types (4 to 9) and modify their appearance. We need to do this with regular expression matching because the actual message (Like "You chat to Player,") is hard-coded into MUSHclient.

I am using a table of regular expressions, with the "before" being the key, and the "after" being the replacement. The plugin keeps scanning through the table until it gets a match. To save mucking around with the imbedded colour codes it uses StripANSI to convert the message back to raw text. If you really want the colours in the resulting message you would need to use ANSI in the replacement text and call AnsiNote to display it.



-- OnPluginChatDisplay
-- ------------------
--
--  MUSHclient is about to display message: type, text
--  Return TRUE to use the default display, FALSE to not display
--
--  Note - the message type number, which groups types
--         of messages, as follows:
--

--   0 Connection attempt    
--   1 Session start, end          
--   2 Name Change        
--   3 Message           
--   4 Incoming Personal  
--   5 Incoming Everybody 
--   6 Incoming Group     
--   7 Outgoing Personal  
--   8 Outgoing Everybody 
--   9 Outgoing Group     
--  10 Peek List          
--  11 Connection List    
--  12 Ping              
--  13 Information       
--  14 File              
--  15 Snoop Data         
--  16 Command

-- table of conversions of chat messages

chat_conversions = {

  -- outgoing
     ["^You chat to (.+), "] = "Me says ",
     ["^You emote to (.+): (.+) "] = "Me ",
  
  -- incoming   
     ["^(.+) chats to (.+), "] = "%1 says ",
     ["^To you, (.+) "] = "%1 ",

}    -- end of chat_conversions table

function OnPluginChatDisplay (message, sText)
  local k, v, count
  
  if message >= 4 and message <= 9 then

-- adjust message text

     sText = StripANSI (sText)
     
     for k, v in pairs (chat_conversions) do
       sText, count = string.gsub (sText, k, v, 1) 
       if count > 0 then
          break
       end -- if
     end -- for
          
     ColourNote ("red", "black", sText)
                  
    return false
  end -- if 
  

  return true -- display it

end -- function


- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


10,235 views.

Posting of new messages is disabled at present.

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.