RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Bus DriverDamage GoalDemolition DerbyDistance GoalDrift GoalFinish Race GoalNo-Move GoalPosition GoalQuick RaceQuick Race LoaderRace MarkersRace DebugRace Goals ManagerRace UIScenario HelperScenario EngineScenarios LoaderSpeed GoalTime Limit GoalWaypoint ActionScenario Waypoints

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 Extensionsscenario

Race Goals Manager

Central manager that initializes, validates, and dispatches race goal events to individual goal modules. Acts as the bridge between the scenario system and goal implementations.

Central manager that initializes, validates, and dispatches race goal events to individual goal modules. Acts as the bridge between the scenario system and goal implementations.


Internal State

FieldTypeDescription
M.onRaceEndvariesAssigned as onRaceEnd

Public API

FunctionSignatureDescription
M.initialiseGoals()Parses vehicle goals from scenario JSON, loads goal modules
M.onRaceStart()Dispatches onRaceStart to all goals
M.onRaceInit()Dispatches onRaceInit to all goals
M.onRaceWaypointReached(data)Dispatches waypoint event to all goals
M.onRaceTick(raceTickTime, scenarioTimer)Dispatches tick to all goals
M.onRaceResult(status)Dispatches race result to all goals
M.onCountdownEnded()Dispatches countdown end to all goals
M.updateGoalsFinalStatus()Calls updateFinalStatus on all loaded goals
M.state- (table field)Shared state table: {goals = {}} - populated by initialiseGoals

Goal Schema

Defines expected types for each goal's JSON fields:

Goal IDFields
timeLimitmsg, maxTime, countdown, waitTime
nomovemsg, triggerEndOnly
positionmsg, purpose, endPoint
damagemsg, purpose, damageLimit, damageThreshold
distancemsg, purpose, maxDistance, minDistance, distanceEnable, target
speedmsg, purpose, maxSpeed, minSpeed, maxTimeout, wayPointNum, delay
driftmsg, failMsg, minDrift, maxDrift, timeAllowance
finishRacepassed, failed, mustWin
wayPointActionwayPointNum, wayPointMsg

Goal Loading

Goals are loaded as Lua modules with these search paths:

  1. scenario/<goalName>.lua
  2. scenario/<goalName>goal.lua

Each goal module must implement:

  • init(scenario) - Parse and validate goal instances
  • processState(scenario, state, stateData) - Handle events
  • updateFinalStatus(scenario) - Report final results

How It Works

  1. initialiseGoals iterates all scenario vehicles
  2. For each vehicle with goals defined, creates goal instances with:
    • vehicleName, vId, id, value, status, startPos
  3. Validates goal fields against goalSchema
  4. Loads goal modules via require() and calls init() on each
  5. Event hooks (onRaceTick, onRaceResult, etc.) dispatch to all loaded goals

Goal Instance Structure

{
  vehicleName = "scenario_player0",
  vId = 12345,              -- vehicle object ID
  id = "damage",            -- goal type name
  value = { damageLimit = 500, purpose = "fail" },
  status = {},              -- result tracking
  startPos = vec3(...)      -- vehicle position at init
}

Usage Examples

-- Goals are defined in scenario JSON under vehicles:
{
  "vehicles": {
    "scenario_player0": {
      "goal": {
        "damage": {"damageLimit": 500},
        "finishRace": {"mustWin": true}
      }
    },
    "*": {
      "goal": {
        "finishRace": {}
      }
    }
  }
}
-- The "*" wildcard applies goals to all vehicles without explicit goals

Key Notes

  • Wildcard "*" vehicle goals apply to vehicles without explicit goal definitions
  • Schema validation logs errors but doesn't prevent goal loading
  • Supports localizedString type (either a string or {txt: "...", context: {...}})
  • Goals can be arrays (unnamed) or objects (keyed by goal ID)
  • Fires onRaceGoalsInitilised hook after all goals are loaded

See Also

  • Scenario Bus Driver - Bus Route Scenario Logic - Related reference
  • Scenario Damage Goal - Damage-Based Win/Fail Condition - Related reference
  • Scenario Demolition Derby - Last Vehicle Moving Wins - Related reference
  • Scenario System Guide - Guide

Race Debug

Provides debug visualization for race waypoints and paths. Draws waypoint spheres and route prisms in the 3D world when editor mode and debug setting are enabled.

Race UI

Manages the in-game HUD for race scenarios - tracks waypoint progress, lap changes, and checkpoint time comparisons. Sends data to the UI via `guihooks.trigger`.

On this page

Internal StatePublic APIGoal SchemaGoal LoadingHow It WorksGoal Instance StructureUsage ExamplesKey NotesSee Also