RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Gameplay AchievementGameplay CityDiscoverForce FieldGarage ModeMarker InteractionParking SystemGameplay Playmode MarkersGameplay PoliceGameplay RallyGameplay Rally LoopGameplay Raw POIsGameplay Skidpad TestSpeed Trap LeaderboardsSpeed Traps and CamerasGameplay StatisticsTaxi Ride SystemTraffic SystemVehicle PerformanceWalking
Sites Custom FieldsSites LocationSites Parking SpotSites ContainerSites ManagerSites Zone

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE Extensionsgameplaysites

Sites Zone

Class representing a 2D polygon zone with optional top/bottom bounding planes. Used for defining areas (parking zones, restricted areas, etc.) within the sites system.

Class representing a 2D polygon zone with optional top/bottom bounding planes. Used for defining areas (parking zones, restricted areas, etc.) within the sites system.


Constructor

local Zone = require('gameplay/sites/zone')
local zone = Zone(sites, name, forceId)

Methods

MethodSignatureReturnsDescription
addVertex(pos, index)nilAdd vertex to polygon
removeVertex(index)nilRemove vertex by index
processVertices()nilRecompute AABB, center, linked list
containsPoint2D(point)boolPoint-in-polygon test with plane check
containsVehicle(veh, basic)boolCheck if vehicle is inside zone
autoPlanes(ignoreTop, ignoreBot)nilAuto-generate bounding planes
changedPlanes()nilReprocess after plane change
validPlanes()boolCheck plane normals are correct
pointBetweenPlanes(point)boolCheck point is between top/bot planes
rayIntersectsZone(rayPos, rayDir)numberRay-zone intersection distance
zoneArea()numberCompute polygon area (shoelace formula)
makeHighResolutionFence(maxStep)nilSubdivide edges for terrain-following
drawDebug(drawMode, clr, height, down, nearCam, drawDist)nilDraw fence visualization
drawMinimap(td)nilDraw zone outline on minimap
onSerialize / onDeserialized--JSON persistence

Key Fields

FieldTypeDescription
verticesarray{pos, index, next, prev, radius} linked list
centervec3Computed centroid
aabbtableAxis-aligned bounding box
top / bottable{pos, normal, active} bounding planes
customFieldsCustomFieldsTags and typed fields
fenceDown / fenceHeightnumberFence drawing extents

How It Works

Point-in-Polygon (containsPoint2D)

  1. AABB quick-reject test
  2. Plane bounds check (if active)
  3. Ray-casting algorithm counting edge crossings

Bounding Planes

Optional top/bottom planes constrain the zone vertically. Plane normals must point up (top) and down (bot). autoPlanes() generates them ±5 units from vertex extremes.

Fence Drawing

Draws triangulated fence panels between vertices. Supports plane-aware height and distance-based alpha fade.

local zone = Zone(parentSites, "Parking Area")
zone:addVertex(vec3(0, 0, 0))
zone:addVertex(vec3(10, 0, 0))
zone:addVertex(vec3(10, 10, 0))
zone:addVertex(vec3(0, 10, 0))
zone:autoPlanes()

-- Check containment
if zone:containsPoint2D(playerPos) then
  print("Player is in zone:", zone.name)
end

-- Area
print("Zone area:", zone:zoneArea(), "sq meters")

Dependencies

  • gameplay/sites/customFields - custom field system
  • core_camera - distance culling
  • core_terrain - terrain height for high-res fences
  • ui_apps_minimap_utils - minimap coordinate conversion
FunctionSignatureReturnsDescription
M.init(sites, name, forceId)nilinit
M.vertexPlaneIntersection(vertex, plane)nilvertexPlaneIntersection
M.aabbCheck(point)nilaabbCheck
M.drawPlane(plane, clrF)nildrawPlane
M.drawFence(from, to, clrI, down, up, usePlanes, nearCam, drawDistance, shapeAlpha)nildrawFence

See Also

  • Sites Custom Fields - Related reference
  • Sites Location - Related reference
  • Sites Parking Spot - Related reference
  • Gameplay Systems Guide - Guide

Sites Manager

Extension that manages loading, caching, and lifecycle of `*.sites.json` files across all levels. Provides utility functions for finding sites files and best parking spots.

J-Turn Detection

Reference for `gameplay_statisticModules_watchJturn`, a statistic submodule that detects J-turn maneuvers (reversing at speed, then spinning 180° to drive forward).

On this page

ConstructorMethodsKey FieldsHow It WorksPoint-in-Polygon (containsPoint2D)Bounding PlanesFence DrawingDependenciesSee Also