GE Lua Documentation

Press F to search!

getZonesByPrioForPosition

Definition


-- @/lua/ge/extensions/gameplay/city.lua:13

local function getZonesByPrioForPosition(pos) -- returns a dict of zones that contain the position, and the highest priority value to use as a key
  local zonesByPrio = { [-math.huge] = {}}
  local highestPrio = -math.huge

  if not sites then return zonesByPrio, highestPrio end

  for _, zone in ipairs(sites:getZonesForPosition(pos)) do
    local prio = zone.customFields:get(prioFieldName) or 0
    zonesByPrio[prio] = zonesByPrio[prio] or {}
    table.insert(zonesByPrio[prio], zone)
    highestPrio = math.max(highestPrio, prio)
  end

  return zonesByPrio, highestPrio
end

Callers