I've seen multiple chat-coloring mods, I'm author of ignore and I have two or three features yet in mind. But current state of the minetest API is making independent mods work together hard. As I'm going to write more single-purpose mods for chat anyway, I'd like to come up with a base lib good enough to be used by more than one modder.
Right now, altering messages is done by
- Hooking on minetest.register_on_receiving_chat_message
- When recieving message, parsing it (per-mod) to get out useful information
- Make the edit in the text
- Literally printing the message to text console
- Returning true, cutting of any mod that would like to touch that message too.
My basic idea is
- The lib will hook on minetest.register_on_receiving_chat_message - with current api, it MUST be the single callback hooked *sigh*
- Turn the message string into table, giving important metadata to modders with no hardcoding in the mods
- Run the message table through all registered callbacks
- Unless told not to do so, print the message to chat
Code: Select all
minetest.register_on_receiving_chat_message(function(msg_string) msg = msgstr_to_table(msg_string) -- you can access msg.author, msg.text, msg.type etc. for cb in registered_callbacks do msg = cb(msg) end if msg.printme then msg_string = msgtbl_to_string(msg) minetest.display_message(msg_string) end end)
I'd like you to tell me:
- Do you like the idea, i.e. would you be willing to convert your mods from hollow minetest api to the new csm chat lib
- What fields in the msg_table would you like to have access to
- What types of messages do you find in-game
- E 20200525-1827: link to irc log fixed