diff options
author | Elijah Duffy <enduffy2014@outlook.com> | 2020-10-03 09:38:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-03 17:38:08 +0100 |
commit | 7d3641021b755be133dea58404fcb039211fbe52 (patch) | |
tree | bd62b4e197492242c84d6e001dfefc8090389b33 /builtin/game/chat.lua | |
parent | 07500479191ed927ab661b3758ffcd2fd43158c5 (diff) | |
download | minetest-7d3641021b755be133dea58404fcb039211fbe52.tar.xz |
Lua API: Add register_on_chatcommand to SSM and CSM (#7862)
Allows catching a chatcommand call just after the command and the
parameters are parsed but before its existence is checked and before the
corresponding function is run. Returning `true` from a callback function
will prevent default handling of the command leaving mods to handle the
command manually.
Diffstat (limited to 'builtin/game/chat.lua')
-rw-r--r-- | builtin/game/chat.lua | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/builtin/game/chat.lua b/builtin/game/chat.lua index 1d277730a..945707623 100644 --- a/builtin/game/chat.lua +++ b/builtin/game/chat.lua @@ -58,6 +58,11 @@ core.register_on_chat_message(function(name, message) param = param or "" + -- Run core.registered_on_chatcommands callbacks. + if core.run_callbacks(core.registered_on_chatcommands, 5, name, cmd, param) then + return true + end + local cmd_def = core.registered_chatcommands[cmd] if not cmd_def then core.chat_send_player(name, "-!- Invalid command: " .. cmd) |