mirror of
https://github.com/minetest/minetest.git
synced 2024-11-30 11:33:44 +01:00
30 lines
895 B
Lua
30 lines
895 B
Lua
-- Minetest: builtin/common/chatcommands.lua
|
|
|
|
core.registered_chatcommands = {}
|
|
|
|
function core.register_chatcommand(cmd, def)
|
|
def = def or {}
|
|
def.params = def.params or ""
|
|
def.description = def.description or ""
|
|
def.privs = def.privs or {}
|
|
def.mod_origin = core.get_current_modname() or "??"
|
|
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 |