Skip to content

Commit

Permalink
cleanup as suggested by SmallJoker
Browse files Browse the repository at this point in the history
  • Loading branch information
SwissalpS committed Sep 8, 2024
1 parent fd6d7e4 commit 56763e1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ end
-- Returns smallest area at position and its id or nil.
-- If multiple areas have the same volume, larger id takes precedence.
function areas:getSmallestAreaAtPos(pos)
local smallest_area, smallest_id, smallest_volume, volume = nil
local smallest_area, smallest_id, volume
local smallest_volume = math.huge
for id, area in pairs(self:getAreasAtPos(pos)) do
volume = (area.pos2.x - area.pos1.x + 1)
* (area.pos2.y - area.pos1.y + 1)
* (area.pos2.z - area.pos1.z + 1)
if not smallest_volume or smallest_volume >= volume then
if smallest_volume >= volume then
smallest_area = area
smallest_id = id
smallest_volume = volume
Expand Down

0 comments on commit 56763e1

Please sign in to comment.