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
Drag Race DebugDrag Tree DisplayDrag Race APIDrag Racing ManagerDrag Strip Save SystemDrag Race TimingDrag Race Phases

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 Extensionsgameplaydrag

Drag Race Phases

Reference for `gameplay_drag_utils`, which provides all phase functions (`stage`, `countdown`, `race`, `stop`, `emergencyStop`), racer position tracking, tree light processing, win conditions, and bou

Reference for gameplay_drag_utils, which provides all phase functions (stage, countdown, race, stop, emergencyStop), racer position tracking, tree light processing, win conditions, and boundary checking.


Dependencies

gameplay_drag_general


Exports

Core Utilities

| Function | Signature | Description | |------ | M.dependencies | table | {'gameplay_drag_general'} |----|-----------|-------------| | onExtensionLoaded | () | Fetch drag data reference | | updateRacer | (racer) | Refresh position, speed, wheel positions, tree lights | | getFrontWheelDistanceFromStagePos | (racer) → number | Signed distance from stage line | | calculateDistanceOfAllWheelsFromStagePos | (racer) | Compute per-axle distances | | isRacerInsideBoundary | (racer) → bool | OBB containment check |

Race Management

FunctionSignatureDescription
generateWinData() → tableDetermine winner, trigger winner light
changeRacerPhase(racer)Advance racer to next phase
changeAllPhases()Advance all racers (dependency phases)
startRaceFromTree(vehId)Mark countdown complete, add AI delay
setDialsData(data)Calculate dial offsets for staggered starts

Phase Functions

FunctionSignatureDescription
stage(phase, racer, dtSim)Drive AI to stage line; check player staging
countdown(phase, racer, dtSim)Activate tree, arm AI (transbrake/two-step/NOS)
race(phase, racer, dtSim)Launch AI, track times, check boundaries/DQ
stop(phase, racer, dtSim)Decelerate to < 15 m/s
emergencyStop(phase, racer, dtSim)Full stop to < 0.01 m/s

Win Conditions

Drag TypeFunctionLogic
headsUpDrag / headsUpRace / dragPracticeRaceheadsUpWin()Lowest time_1_4 wins; DQ'd racers last
bracketRacebracketWin()Closest positive dialDiff wins; negative (breakout) penalised; DQ'd last
-- Bracket win calculation per racer:
dialDiff = (time_1_4 + reactionTime) - dial
-- Positive dialDiff = slower than dial (valid)
-- Negative dialDiff = faster than dial (breakout, penalised)
-- Sorted: positive ascending, then negative by abs ascending, then DQ'd

Tree Light Processing

-- Pre-stage and stage lights are controlled by front wheel distance:
-- preStage zone: [-0.356m, 0m)     (±0.178m around -0.178m)
-- stage zone:    [-0.178m, +0.178m) (±0.178m around 0m)
-- exit zone:     > 0.4m from 0

processTreeLights compares distance against thresholds and fires preStageLightOn/Off and stageLightOn/Off hooks when state changes.


AI Vehicle Control

During stage phase, AI vehicles:

veh:queueLuaCommand('ai.setSpeedMode("limit")')
veh:queueLuaCommand('ai.setSpeed(5)')
veh:queueLuaCommand('ai.setTarget("endLine_1")')

During countdown phase, AI arms launch systems:

-- Activate transbrake (or freeze if unavailable)
-- Activate two-step rev limiter
-- Arm nitrous oxide injection
-- Set throttle override to 0.8

During race phase, AI launches:

-- Release transbrake/freeze
-- Clear throttle override
-- Activate JATO if available
-- Set AI to full speed toward end line

Disqualification Checks

CheckConditionReason
stageJumpFront wheels outside ±0.178m during countdown"jumping"
outOfBoundsOutside lane boundary OBB or distance < -0.33m"outOfLane"
stationaryTooLongSpeed < 1 m/s for > 5 seconds during race"stationaryTooLong"

Key Behaviors

  • updateRacer transforms wheel offsets from local to world space using vehicle rotation, then calculates per-axle distances from stage
  • setDialsData with 2 racers computes staggered offset: slower racer gets 0, faster gets abs(dial1 - dial2)
  • AI vehicles get a random 0–0.5s reaction delay via randomDelayTimer on green light
  • Player staging requires 1 second hold at the stage line with wheels parallel (dot product ≥ 0.70)
  • Timeslip is auto-sent to UI when finish is reached outside of a formal mission

Module Variables

VariableTypeDescription
M.dependenciestable{'gameplay_drag_general'}
M.calculateDistanceOfAllWheelsFromStagePos(racer)-
M.changeAllPhases()-
M.changeRacerPhase(racer)-
M.countdown(phase, racer, dtSim)-
M.emergencyStop(phase, racer, dtSim)-
M.generateWinData()-
M.getFrontWheelDistanceFromStagePos(racer)-
M.isRacerInsideBoundary(racer)-
M.onExtensionLoaded()-
M.race(phase, racer, dtSim)-
M.setDialsData(data)-
M.stage(phase, racer, dtSim)-
M.startRaceFromTree(vehId)-
M.stop(phase, racer, dtSim)-
M.updateRacer(racer)-

See Also

  • drag/debug - Drag Race Debug Menu - Related reference
  • drag/display - Christmas Tree & Display Signs - Related reference
  • drag/dragBridge - Flowgraph / External API Bridge - Related reference
  • Gameplay Systems Guide - Guide

Drag Race Timing

Reference for `gameplay_drag_times`, which tracks all distance-based, velocity-based, and time-based measurements during a drag race.

Bracket Drag Race

Reference for `gameplay_drag_dragTypes_bracketRace`, which implements the bracket-style drag race where racers have a dial-in time and staggered starts.

On this page

DependenciesExportsCore UtilitiesRace ManagementPhase FunctionsWin ConditionsTree Light ProcessingAI Vehicle ControlDisqualification ChecksKey BehaviorsModule VariablesSee Also