mirror of
https://github.com/minetest-mods/areas.git
synced 2024-12-24 17:50:40 +01:00
Allow protection of intersecting sub-areas and make error message more informative
This commit is contained in:
parent
1a5efd07f1
commit
78ca95d5b4
18
internal.lua
18
internal.lua
@ -136,25 +136,25 @@ function areas:canPlayerAddArea(pos1, pos2, name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if count >= self.self_protection_max_areas then
|
if count >= self.self_protection_max_areas then
|
||||||
return false, "You have reached the maximum amount"
|
return false, "You have reached the maximum amount of"
|
||||||
.." of areas that you are allowed to"
|
.." areas that you are allowed to protect."
|
||||||
.." protect."
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check intersecting areas
|
-- Check intersecting areas
|
||||||
for _, area in pairs(self.areas) do
|
for id, area in pairs(self.areas) do
|
||||||
if (area.pos1.x <= pos2.x and area.pos2.x >= pos1.x) and
|
if (area.pos1.x <= pos2.x and area.pos2.x >= pos1.x) and
|
||||||
(area.pos1.y <= pos2.y and area.pos2.y >= pos1.y) and
|
(area.pos1.y <= pos2.y and area.pos2.y >= pos1.y) and
|
||||||
(area.pos1.z <= pos2.z and area.pos2.z >= pos1.z) then
|
(area.pos1.z <= pos2.z and area.pos2.z >= pos1.z) then
|
||||||
--Found an area intersecting with the suplied area
|
-- Found an area intersecting with the suplied area
|
||||||
if area.owner ~= name then
|
if not areas:isAreaOwner(id, name) then
|
||||||
return false, "The area intersects with an"
|
return false, ("The area intersects with"
|
||||||
.." area that you do not own."
|
.." %s [%u] owned by %s.")
|
||||||
|
:format(area.name, id, area.owner)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return true, ""
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Given a id returns a string in the format:
|
-- Given a id returns a string in the format:
|
||||||
|
Loading…
Reference in New Issue
Block a user