Skip to content

Commit

Permalink
backward compat with [areas]
Browse files Browse the repository at this point in the history
  • Loading branch information
SwissalpS committed Sep 16, 2024
1 parent b868de7 commit d77158f
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions areas.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,30 @@ end
-- protection check
local old_is_protected = minetest.is_protected
function minetest.is_protected(pos, name)
local _, id = areas:getSmallestAreaAtPos(pos)
local xp_area = id and xp_areas[id]
if xp_area then
local xp = xp_redo.get_xp(name)
if xp_area.min and xp < xp_area.min then
return true
elseif xp_area.max and xp > xp_area.max then
return true
if areas.getSmallestAreaAtPos then
local _, id = areas:getSmallestAreaAtPos(pos)
local xp_area = id and xp_areas[id]
if xp_area then
local xp = xp_redo.get_xp(name)
if xp_area.min and xp < xp_area.min then
return true
elseif xp_area.max and xp > xp_area.max then
return true
end
end
else
local area_list = areas:getAreasAtPos(pos)
for id in pairs(area_list) do
local xp_area = xp_areas[id]

if xp_area then
local xp = xp_redo.get_xp(name)
if xp_area.min and xp < xp_area.min then
return true
elseif xp_area.max and xp > xp_area.max then
return true
end
end
end
end

Expand Down

0 comments on commit d77158f

Please sign in to comment.