2021-06-30 01:53:14 +00:00
|
|
|
local we_c = worldeditadditions_core
|
|
|
|
function we_c.override_command(name, def)
|
2021-08-03 01:54:18 +00:00
|
|
|
local def = table.copy(def)
|
|
|
|
local success, err = we_c.check_command(name, def)
|
2021-11-07 14:31:01 +00:00
|
|
|
|
2021-06-30 01:53:14 +00:00
|
|
|
if not success then
|
2021-08-03 01:54:18 +00:00
|
|
|
error(err)
|
|
|
|
return false
|
2021-06-30 01:53:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
minetest.override_chatcommand("/" .. name, {
|
|
|
|
privs = def.privs,
|
|
|
|
params = def.params,
|
|
|
|
description = def.description,
|
|
|
|
func = function(player_name, param)
|
2021-06-30 15:36:04 +00:00
|
|
|
return we_c.chatcommand_handler(name, player_name, param)
|
2021-06-30 01:53:14 +00:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
worldedit.registered_commands[name] = def
|
|
|
|
end
|
2021-08-03 01:54:18 +00:00
|
|
|
|
|
|
|
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
|