Page 1 of 1

Remove C++ Chat Handler, replace with overridable Lua

PostPosted: Wed Mar 20, 2013 17:09
by Traxie21
At the moment, Chat is automagically sent to the sender's client when typed. This may not seem like a big deal, until someone decides they want to format chat.

For example: If you type "TEST" in chat now, you get this.

<username> TEST

Others see this:

<username> TEST

With this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_chat_message(function(name, message)
    playerdata = load_player_data()
    minetest.chat_send_all("["..playerdata[name]['rank'].."] "..name..": "..message..".")
    return true
end)



you get this:

<username> TEST
[Players] username: TEST.

others see this:

[Players] username: TEST.

So, basically, it works, but the sender gets a redundant message with the default formatting, as well as the new format.

I suggest removing the C++ that does this, and instead using

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all

minetest.register_on_chat_message(function(name, message)
    chatmessage()
end)

function chatmessage(name, message)
minetest.chat_send_all("<"..name.."> "..message)
    return true
end

in chatcommands.lua in /builtin.
This would allow other mods to override the chatmessage function to achieve the required effect.

I tested this, and the lua is only a fraction of a second slower, no one really cares about lightning-fast chat afaik. It would also tell you when the server is lagging. XD

PostPosted: Wed Mar 20, 2013 17:24
by Tedypig
OK, as you may know, I'm a little slow when it comes to coding, BUT this seems like if it were implemented we would be able to have titles. Am I right on that (probably not lol)?

PostPosted: Wed Mar 20, 2013 17:29
by 0gb.us
I've actually run into this issue myself. Although, what I wanted to do was rather hacky, so I figured I'd just scrap my project.

PostPosted: Wed Mar 20, 2013 17:29
by kaeza
Tedypig wrote:OK, as you may know, I'm a little slow when it comes to coding, BUT this seems like if it were implemented we would be able to have titles. Am I right on that (probably not lol)?

yes, you are slow when it comes to coding.
oh wait... that wasn't your question lol
Just Kidding :)

Maybe related: Remove that ugly "-!- Server:" prefix for messages sent with minetest.chat_send_player().

PostPosted: Wed Mar 20, 2013 17:38
by Traxie21
I actually fully implemented titles in ServerExtended. In the se_startup config, you can change chat_string to use &r for rank, &n for name, and &m for message.

The only problem is the clientside <name> Message.