alias override

This commit is contained in:
VorTechnix 2021-08-02 18:54:18 -07:00
parent 77ffda46f7
commit f9ac0e65ec

@ -1,9 +1,11 @@
local we_c = worldeditadditions_core
function we_c.override_command(name, def)
local success, def = we_c.check(def)
local def = table.copy(def)
local success, err = we_c.check_command(name, def)
if not success then
return false, def
error(err)
return false
end
minetest.override_chatcommand("/" .. name, {
@ -16,3 +18,18 @@ function we_c.override_command(name, def)
})
worldedit.registered_commands[name] = def
end
function we_c.alias_override(alias, original)
if not worldedit.registered_commands[original] then
minetest.log("error", "worldedit_shortcommands: original " .. original .. " does not exist")
return
end
if minetest.chatcommands["/" .. alias] then
minetest.override_chatcommand("/" .. alias, minetest.chatcommands["/" .. original])
worldedit.registered_commands[alias] = worldedit.registered_commands[original]
else
minetest.register_chatcommand("/" .. alias, minetest.chatcommands["/" .. original])
worldedit.registered_commands[alias] = worldedit.registered_commands[original]
end
end