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 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`.

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.


Public API (Exports)

FunctionSignatureDescription
M.initialise(scenario)Resets waypoint times and clears UI
M.onRaceStart()Sets initial waypoint/lap counts in UI
M.onScenarioChange(scenario)Clears waypoint UI on pre-start or nil
M.onRaceWaypointReached(data)Updates waypoint counter, computes time comparisons
M.onRaceLap(data)Updates lap counter, shows lap time message

How It Works

Initialization

  1. initialise resets lastWaypointTimes table and sends nil to WayPointChange and RaceLapChange
  2. onRaceStart sends initial waypoint count (from initialLapConfig) and lap count to UI

Waypoint Tracking

  1. onRaceWaypointReached records the time for each waypoint crossing
  2. If enough historical data exists, computes:
    • Checkpoint comparison: Time delta for this segment vs. previous lap's same segment
    • Overall comparison: Cumulative time delta for this position in the lap
  3. Sends RaceCheckpointComparison and RaceTimeComparison with 5-second timeout
  4. Updates WayPointChange with {current, count} for the progress bar

Lap Tracking

  1. onRaceLap updates the current lap number (capped at scenario.lapCount)
  2. For infinite laps (lapCount == 0), increments without limit
  3. Shows lap time via ui_message with formatted seconds

UI Events Triggered

EventDataWhen
WayPointChange{current, count} or nilWaypoint reached or reset
RaceLapChange{current, count} or nilLap completed or reset
RaceCheckpointComparison{timeOut, time}Checkpoint time delta available
RaceTimeComparison{timeOut, time}Overall lap time delta available

Usage Example

-- Automatically loaded by scenario system
-- Hook events fire from scenario_waypoints when checkpoints are crossed

-- Manual initialization:
scenario_raceUI.initialise(scenario)

-- Time comparison data sent to UI:
-- positive time = slower than last lap
-- negative time = faster than last lap

Key Notes

  • Only tracks the player vehicle (be:getPlayerVehicleID(0))
  • Time comparisons require at least 2 laps of data
  • Respects scenario.disableWaypointTimes flag (for branching waypoints)
  • Lap time formatted as "MM:SS.sss" via string.format

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 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.

Scenario Helper

Utility library for scenario scripting. Provides helper functions to queue Lua commands on vehicles, configure AI behavior, flash UI messages, and measure distances between scene objects.

On this page

Public API (Exports)How It WorksInitializationWaypoint TrackingLap TrackingUI Events TriggeredUsage ExampleKey NotesSee Also