From fe5266404358a9107938db76bcec7a3d280434ab Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Tue, 11 Nov 2014 17:27:35 -0500 Subject: [PATCH] Add move_area command --- chatcommands.lua | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/chatcommands.lua b/chatcommands.lua index 9123957..d716cb7 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -239,12 +239,11 @@ minetest.register_chatcommand("change_owner", { description = "Change the owner of an area using it's ID", func = function(name, param) local id, newOwner = param:match("^(%d+)%s(%S+)$") - if not id then return false, "Invalid usage, see" .." /help change_owner." end - + if not areas:player_exists(newOwner) then return false, "The player \""..newOwner .."\" does not exist." @@ -270,7 +269,6 @@ minetest.register_chatcommand("area_open", { description = "Toggle an area open (anyone can interact) or closed", func = function(name, param) local id = tonumber(param) - if not id then return false, "Invalid usage, see /help area_open." end @@ -287,3 +285,31 @@ minetest.register_chatcommand("area_open", { end }) + +minetest.register_chatcommand("move_area", { + params = "", + description = "Move (or resize) an area to the current positions.", + privs = areas.adminPrivs, + func = function(name, param) + local id = tonumber(param) + if not id then + return false, "Invalid usage, see /help move_area." + end + + local area = areas.areas[id] + if not area then + return false, "Area does not exist." + end + + local pos1, pos2 = areas:getPos(name) + if not pos1 then + return false, "You need to select an area first." + end + + area.pos1 = pos1 + area.pos2 = pos2 + areas:save() + return true, "Area successfully moved." + end, +}) +