API ReferenceGE Extensionsgameplaysites
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.
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.
Constructor
local Location = require('gameplay/sites/location')
local loc = Location(sites, name, forceId)| Parameter | Type | Description |
|---|---|---|
sites | object | Parent sites container (provides getNextUniqueIdentifier) |
name | string? | Display name (defaults to "Location N") |
forceId | number? | Override auto-generated ID |
Methods
| Method | Signature | Returns | Description |
|---|---|---|---|
set | (pos, radius) | nil | Set position and radius |
drawDebug | (drawMode, clr) | nil | Draw sphere + name label + closest road info |
findClosestRoadInfo | () | table? | Find nearest road segment from map graph |
onSerialize | () | table | Serialize to JSON |
onDeserialized | (data) | nil | Restore from JSON data |
Fields
| Field | Type | Default | Description |
|---|---|---|---|
pos | vec3 | (0,0,0) | World position |
radius | number | 5 | Interaction radius |
color | vec3 | (1,1,1) | Display color (RGB floats) |
customFields | CustomFields | new | Custom typed fields and tags |
_drawMode | string | "faded" | Drawing mode: faded, normal, highlight, none |
How It Works
- Location is a sphere in 3D space with a name label
- Debug drawing adapts to
drawMode- highlight mode also shows the closest road segment findClosestRoadInfo()usesmap.findClosestRoadto locate the nearest graph edge, then projects the location onto that edge
local loc = Location(parentSites, "Gas Station")
loc:set(vec3(100, 200, 50), 10)
-- Find closest road
local road = loc:findClosestRoadInfo()
if road then
print(road.name_a, road.name_b, road.distance)
print("Projected pos:", road.pos)
endDependencies
gameplay/sites/customFields- custom field systemmap-findClosestRoad,getMap().nodescore_camera- distance cullingeditor- draw distance preference
Notes
- Draw distance respects editor preference
gizmos.visualization.visualizationDrawDistance(default 300) - The
xnormOnLineprojection for closest road is clamped to [0, 1] and swapped if closer to second point
| Function | Signature | Returns | Description |
|---|---|---|---|
M.init | (sites, name, forceId) | nil | init |
See Also
- Sites Custom Fields - Related reference
- Sites Parking Spot - Related reference
- Sites Container - Related reference
- Gameplay Systems Guide - Guide
Sites Custom Fields
Class for managing typed custom fields and tags on sites objects (locations, zones, parking spots). Supports `string`, `number`, and `vec3` field types plus a tag set.
Sites Parking Spot
Class representing an oriented 3D parking box. Supports multi-spot generation (rows of spots), vehicle parking validation, and safe vehicle teleportation.