Remove C++ Chat Handler, replace with overridable Lua

User avatar
Traxie21
Member
 
Posts: 753
Joined: Mon Dec 31, 2012 10:48

Remove C++ Chat Handler, replace with overridable Lua

by Traxie21 » Wed Mar 20, 2013 17:09

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
 

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Wed Mar 20, 2013 17:24

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)?
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55

by 0gb.us » Wed Mar 20, 2013 17:29

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.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Wed Mar 20, 2013 17:29

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().
Last edited by kaeza on Wed Mar 20, 2013 18:09, edited 1 time in total.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
Traxie21
Member
 
Posts: 753
Joined: Mon Dec 31, 2012 10:48

by Traxie21 » Wed Mar 20, 2013 17:38

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.
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 3 guests

cron