I want to intercept all messages that goes into the chat, not just player messages. I know of minetest.register_on_chat_message but as the docs state it's only
Called always when a player says something
and not every message.
What I really want to do is to move the chat's position but since that seems hardcoded I figure I'll intercept all messages instead. What can I do?
-- Run custom callback before builtin
table.insert(minetest.registered_on_chat_message, 1, function(name, message)
-- Loop through minetest.registered_on_chat_message to execute chat commands or whatever
-- Message handled, abort callback call loop
return true
end)
-- Bad Practice starts here
function minetest.chat_send_player(name, text)
-- custom handler
end
function minetest.chat_send_all(text)
-- custom handler
end
You won't be able to intercept some of the core messages, such as the death message.
Thank you! A better solution if not perfect. What are some other type of core messages I won’t be able to intercept and apart from death messages, are they common?
texmex wrote:Thank you! A better solution if not perfect. What are some other type of core messages I won’t be able to intercept and apart from death messages, are they common?
Probably just the "You died." message because player joins/leaves and the server status are all done with chat_send_player now.
Right, the client error messages are sometimes also visible in-game. You could try to write a CSM to prevent the client from using the regular chat - but error messages are written to the chat internally (no modification possible). For the regular case where you want to chat it's totally sufficient to only replace the server-side commands.
Oh okay. I think I’ll open an issue on the subject of chat positioning instead and re-layout my project’s HUD in the meanwhile. Seems to be time better spent. :)