1 -- Minetest: builtin/common/chatcommands.lua
3 core.registered_chatcommands = {}
5 function core.register_chatcommand(cmd, def)
7 def.params = def.params or ""
8 def.description = def.description or ""
9 def.privs = def.privs or {}
10 def.mod_origin = core.get_current_modname() or "??"
11 core.registered_chatcommands[cmd] = def
14 function core.unregister_chatcommand(name)
15 if core.registered_chatcommands[name] then
16 core.registered_chatcommands[name] = nil
18 core.log("warning", "Not unregistering chatcommand " ..name..
19 " because it doesn't exist.")
23 function core.override_chatcommand(name, redefinition)
24 local chatcommand = core.registered_chatcommands[name]
25 assert(chatcommand, "Attempt to override non-existent chatcommand "..name)
26 for k, v in pairs(redefinition) do
27 rawset(chatcommand, k, v)
29 core.registered_chatcommands[name] = chatcommand