Add move_area command

This commit is contained in:
ShadowNinja 2014-11-11 17:27:35 -05:00
parent 3666f7debb
commit fe52664043
1 changed files with 29 additions and 3 deletions

View File

@ -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 = "<ID>",
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,
})