2021-06-30 01:53:14 +00:00
|
|
|
local we_c = worldeditadditions_core
|
|
|
|
function we_c.register_command(name, def)
|
2021-07-29 22:49:37 +00:00
|
|
|
local def = table.copy(def)
|
|
|
|
local success, err = we_c.check_command(name, def)
|
2021-06-30 01:53:14 +00:00
|
|
|
if not success then
|
2021-07-29 22:49:37 +00:00
|
|
|
return false, err
|
2021-06-30 01:53:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_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-07-29 22:49:37 +00:00
|
|
|
|
|
|
|
function we_c.alias_command(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.log("error", "worldedit_shortcommands: alias " .. alias .. " already exists")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_chatcommand("/" .. alias, minetest.chatcommands["/" .. original])
|
|
|
|
worldedit.registered_commands[alias] = worldedit.registered_commands[original]
|
|
|
|
end
|