Remove C++ Chat Handler, replace with overridable Lua
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:
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
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
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
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