aboutsummaryrefslogtreecommitdiff
path: root/builtin/game/chatcommands.lua
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/game/chatcommands.lua')
-rw-r--r--builtin/game/chatcommands.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua
index 199b9e964..08dc1bb1d 100644
--- a/builtin/game/chatcommands.lua
+++ b/builtin/game/chatcommands.lua
@@ -15,6 +15,24 @@ function core.register_chatcommand(cmd, def)
core.registered_chatcommands[cmd] = def
end
+function core.unregister_chatcommand(name)
+ if core.registered_chatcommands[name] then
+ core.registered_chatcommands[name] = nil
+ else
+ core.log("warning", "Not unregistering chatcommand " ..name..
+ " because it doesn't exist.")
+ end
+end
+
+function core.override_chatcommand(name, redefinition)
+ local chatcommand = core.registered_chatcommands[name]
+ assert(chatcommand, "Attempt to override non-existent chatcommand "..name)
+ for k, v in pairs(redefinition) do
+ rawset(chatcommand, k, v)
+ end
+ core.registered_chatcommands[name] = chatcommand
+end
+
core.register_on_chat_message(function(name, message)
local cmd, param = string.match(message, "^/([^ ]+) *(.*)")
if not param then