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)
| Function | Signature | Description |
|---|---|---|
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
initialiseresetslastWaypointTimestable and sendsniltoWayPointChangeandRaceLapChangeonRaceStartsends initial waypoint count (frominitialLapConfig) and lap count to UI
Waypoint Tracking
onRaceWaypointReachedrecords the time for each waypoint crossing- 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
- Sends
RaceCheckpointComparisonandRaceTimeComparisonwith 5-second timeout - Updates
WayPointChangewith{current, count}for the progress bar
Lap Tracking
onRaceLapupdates the current lap number (capped atscenario.lapCount)- For infinite laps (
lapCount == 0), increments without limit - Shows lap time via
ui_messagewith formatted seconds
UI Events Triggered
| Event | Data | When |
|---|---|---|
WayPointChange | {current, count} or nil | Waypoint reached or reset |
RaceLapChange | {current, count} or nil | Lap 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 lapKey Notes
- Only tracks the player vehicle (
be:getPlayerVehicleID(0)) - Time comparisons require at least 2 laps of data
- Respects
scenario.disableWaypointTimesflag (for branching waypoints) - Lap time formatted as
"MM:SS.sss"viastring.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.