summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaly2 <plangrognet@laposte.net>2016-06-19 19:12:16 +0200
committerShadowNinja <shadowninja@minetest.net>2016-06-23 15:49:22 -0400
commit67507c75918f8a60ad218cdcb69cc8d39e4a55ed (patch)
tree99fc19ed47ba34d28c81375fc67874aecd3fbc1b
parent10338cd5d19fbb5975ca3ba5a481d1a11b04f6b6 (diff)
Fix move_area not updating AreaStore
-rw-r--r--chatcommands.lua5
-rw-r--r--internal.lua14
2 files changed, 17 insertions, 2 deletions
diff --git a/chatcommands.lua b/chatcommands.lua
index d37634a..6079e93 100644
--- a/chatcommands.lua
+++ b/chatcommands.lua
@@ -306,13 +306,14 @@ minetest.register_chatcommand("move_area", {
return false, "You need to select an area first."
end
- area.pos1 = pos1
- area.pos2 = pos2
+ areas:move(id, area, pos1, pos2)
areas:save()
+
return true, "Area successfully moved."
end,
})
+
minetest.register_chatcommand("area_info", {
description = "Get information about area configuration and usage.",
func = function(name, param)
diff --git a/internal.lua b/internal.lua
index d9ff00d..05a31cd 100644
--- a/internal.lua
+++ b/internal.lua
@@ -128,6 +128,20 @@ function areas:remove(id, recurse)
end
end
+--- Move an area.
+function areas:move(id, area, pos1, pos2)
+ area.pos1 = pos1
+ area.pos2 = pos2
+
+ if self.store then
+ self.store:remove_area(areas.store_ids[id])
+ local sid = self.store:insert_area(pos1, pos2, tostring(id))
+ if self:checkAreaStoreId(sid) then
+ self.store_ids[id] = sid
+ end
+ end
+end
+
-- Checks if a area between two points is entirely contained by another area.
-- Positions must be sorted.
function areas:isSubarea(pos1, pos2, id)