GE Lua Documentation

Press F to search!

getAverageDoorPositionForFacility

Definition


-- @/lua/ge/extensions/freeroam/facilities.lua:136


local function getAverageDoorPositionForFacility(facility)
  local center, count = vec3(0,0,0), 0

  for _, pair in ipairs(facility.doors or {}) do
    local obj = scenetree.findObject(pair[1])
    if obj then
      center = center + obj:getPosition()
      count = count + 1
    else
      log("W","","Couldnt not find object " .. pair[1] .. " in scenetree for facility " .. facility.id)
    end
  end

  if count > 0 then
    return center / count
  else
    log("E","","Dealership has no doors and thus no position! " .. facility.id)
    return vec3()
  end
end

Callers

@/lua/ge/extensions/career/modules/vehicleShopping.lua
        local dealership = freeroam_facilities.getDealership(seller.id)
        randomVehicleInfo.pos = freeroam_facilities.getAverageDoorPositionForFacility(dealership)
        local personalityKey = seller.id  -- Use dealership ID as personality key
  if currentSeller then
    local tetherPos = freeroam_facilities.getAverageDoorPositionForFacility(freeroam_facilities.getFacility("dealership",currentSeller))
    tether = career_modules_tether.startSphereTether(tetherPos, tetherRange, M.endShopping)
@/lua/ge/extensions/freeroam/facilities.lua
  local camPos = core_camera.getPosition()
  local center = getAverageDoorPositionForFacility(facility)
  local closest = nil
@/lua/ge/extensions/career/modules/tuning.lua
  -- calculate computer position
  local computerPos = freeroam_facilities.getAverageDoorPositionForFacility(freeroam_facilities.getFacility("computer", originComputerId))
@/lua/ge/extensions/career/modules/partShopping.lua
  -- calculate computer position
  local computerPos = freeroam_facilities.getAverageDoorPositionForFacility(freeroam_facilities.getFacility("computer",originComputerId))
@/lua/ge/extensions/career/modules/computer.lua

  --local computerPos = freeroam_facilities.getAverageDoorPositionForFacility(computerFacility)
  local door = computerFacility.doors[1]