Sites Parking Spot
Class representing an oriented 3D parking box. Supports multi-spot generation (rows of spots), vehicle parking validation, and safe vehicle teleportation.
Class representing an oriented 3D parking box. Supports multi-spot generation (rows of spots), vehicle parking validation, and safe vehicle teleportation.
Constructor
local ParkingSpot = require('gameplay/sites/parkingSpot')
local spot = ParkingSpot(sites, name, forceId)Methods
| Method | Signature | Returns | Description |
|---|---|---|---|
set | (pos, rot, scl) | nil | Set position, rotation, scale |
calcVerts | () | nil | Recalculate 2D corner vertices |
containsPoint | (pos) | bool | Check if point is inside box |
checkParking | (vehId, precision, drivingSpd, parkingSpd) | valid, res | Check if vehicle is correctly parked |
vehicleFits | (vehId) | bool | Check if vehicle dimensions fit spot |
boxFits | (x, y, z) | bool | Check if extents fit spot |
hasAnyVehicles | (playerId) | hasVeh, vehIds | Check for vehicles occupying spot |
generateMultiSpots | (parkingSpotList) | nil | Generate additional spots in a row |
moveResetVehicleTo | (vehId, lowPrec, backwards, offsetPos, offsetRot, safeTele, removeTraf, resetVeh, opts) | pos, rot | Teleport vehicle to this spot |
drawDebug | (drawMode, clr) | nil | Draw oriented box visualization |
getPath | () | string | Sites file path reference |
onSerialize / onDeserialized | - | - | JSON persistence |
Fields
| Field | Type | Description |
|---|---|---|
pos | vec3 | Center position |
rot | quat | Orientation |
scl | vec3 | Dimensions (width, length, height) |
isMultiSpot | bool | Multi-spot generator flag |
multiSpotData | table | {spotAmount, spotOffset, spotDirection, spotRotation} |
customFields | CustomFields | Tags and typed fields |
How It Works
Parking Validation (checkParking)
- Checks vehicle speed ≤
drivingSpeed(5 m/s default) - Gets vehicle OOBB corners based on facing direction
- Scales corners by
precisionfactor toward center - Validates each corner is inside the parking box
- Final check: speed ≤
parkingSpeed(1 m/s)
Multi-Spot Generation
Generates additional spots offset in a direction (Left/Right/Front/Back) with optional rotation:
spot.isMultiSpot = true
spot.multiSpotData = { spotAmount = 4, spotOffset = 0.5, spotDirection = "Left", spotRotation = 0 }Vehicle Teleportation (moveResetVehicleTo)
Supports two modes:
- Safe teleport: Uses
spawn.safeTeleportwith traffic clearing - Precise placement: Computes exact position from OOBB corner alignment
-- Check if vehicle is parked
local valid, corners = spot:checkParking(vehId, 0.8)
-- Teleport vehicle to spot
spot:moveResetVehicleTo(vehId, false, false, nil, nil, true, true, true)Dependencies
gameplay/sites/customFields- custom fieldsspawn-safeTeleportbe- OOBB axis/center queriesmap.objects- vehicle tracking data
| Function | Signature | Returns | Description |
|---|---|---|---|
M.init | (sites, name, forceId) | nil | init |
M.drawSide | (a, b, z, clrI) | nil | drawSide |
M.setToVehicle | (vehId) | nil | setToVehicle |
See Also
- Sites Custom Fields - Related reference
- Sites Location - Related reference
- Sites Container - Related reference
- Gameplay Systems Guide - Guide
Sites Location
Class representing a named point location within the sites system. Has a position, radius, color, and custom fields. Used for marking points of interest within zones.
Sites Container
Class that holds all site data for a level: locations, zones, and parking spots. Provides spatial queries via KD-trees and manages relationships between zones and their contained objects.