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
### Other registration functions
* `minetest.register_chatcommand(cmd, chatcommand definition)`
* Adds definition to minetest.registered_chatcommands
+* `minetest.override_chatcommand(name, redefinition)`
+ * Overrides fields of a chatcommand registered with register_chatcommand.
+* `minetest.unregister_chatcommand(name)`
+ * Unregisters a chatcommands registered with register_chatcommand.
* `minetest.register_privilege(name, definition)`
* `definition`: `"description text"`
* `definition`: `{ description = "description text", give_to_singleplayer = boolean}`