mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-27 17:43:53 +01:00
alias override
This commit is contained in:
parent
77ffda46f7
commit
f9ac0e65ec
@ -1,9 +1,11 @@
|
|||||||
local we_c = worldeditadditions_core
|
local we_c = worldeditadditions_core
|
||||||
function we_c.override_command(name, def)
|
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
|
if not success then
|
||||||
return false, def
|
error(err)
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.override_chatcommand("/" .. name, {
|
minetest.override_chatcommand("/" .. name, {
|
||||||
@ -16,3 +18,18 @@ function we_c.override_command(name, def)
|
|||||||
})
|
})
|
||||||
worldedit.registered_commands[name] = def
|
worldedit.registered_commands[name] = def
|
||||||
end
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user