This commit is contained in:
Megaf 2014-06-22 23:43:40 +00:00
commit e056f87089
1 changed files with 9 additions and 7 deletions

16
api.lua
View File

@ -2,13 +2,15 @@
-- Returns a list of areas that include the provided position -- Returns a list of areas that include the provided position
function areas:getAreasAtPos(pos) function areas:getAreasAtPos(pos)
local a = {} local a = {}
local px, py, pz = pos.x, pos.y, pos.z if pos then
for id, area in pairs(self.areas) do local px, py, pz = pos.x, pos.y, pos.z
local ap1, ap2 = area.pos1, area.pos2 for id, area in pairs(self.areas) do
if px >= ap1.x and px <= ap2.x and local ap1, ap2 = area.pos1, area.pos2
py >= ap1.y and py <= ap2.y and if px >= ap1.x and px <= ap2.x and
pz >= ap1.z and pz <= ap2.z then py >= ap1.y and py <= ap2.y and
a[id] = area pz >= ap1.z and pz <= ap2.z then
a[id] = area
end
end end
end end
return a return a