mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-15 18:57:08 +00:00
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.
This commit is contained in:
parent
0750047919
commit
7d3641021b
8 changed files with 29 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -584,6 +584,7 @@ core.unregister_biome = make_wrap_deregistration(core.register_biome,
|
|||
core.clear_registered_biomes, core.registered_biomes)
|
||||
|
||||
core.registered_on_chat_messages, core.register_on_chat_message = make_registration()
|
||||
core.registered_on_chatcommands, core.register_on_chatcommand = make_registration()
|
||||
core.registered_globalsteps, core.register_globalstep = make_registration()
|
||||
core.registered_playerevents, core.register_playerevent = make_registration()
|
||||
core.registered_on_mods_loaded, core.register_on_mods_loaded = make_registration()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue