GE Lua Documentation

Press F to search!

checkParkingSpot

Definition


-- @/lua/ge/extensions/gameplay/parking.lua:146

local function checkParkingSpot(vehId, parkingSpot) -- checks if a parking spot is ready to use for a parked vehicle
  local obj = getObjectByID(vehId or 0)

  if parkingSpot.vehicle or parkingSpot.ignoreOthers or parkingSpot.customFields.tags.ignoreOthers or parkingSpot:hasAnyVehicles() or not obj then
    return false
  end

  if parkingSpot:vehicleFits(vehId) then
    -- ensure that the parking spot is not too oversized for the vehicle
    local size = obj.initialNodePosBB:getExtents()
    local psSize = parkingSpot.scl
    if size.x / psSize.x < 0.5 or size.y / psSize.y < 0.5 then
      return false
    end
  else
    return false
  end

  return true
end

Callers

@/lua/ge/extensions/gameplay/parking.lua
    local ps = psData.ps
    if psData.squaredDistance >= square(minDist) and psData.squaredDistance <= square(maxDist) and checkParkingSpot(vehId, ps) then
      if parkedVehData[vehId].parkingSpotId then
    local ps = psData.ps
    if ps.pos:squaredDistance(focus.pos) > square(actualViewDist) and checkParkingSpot(newId, ps) then -- prevents respawn if player is too near to parking spot
      vehPool:setVeh(newId, true)