API ReferenceGE Extensionsscenario
Bus Driver
M.dependencies = {'scenario_scenarios', 'core_groundMarkers'}
Dependencies
M.dependencies = {'scenario_scenarios', 'core_groundMarkers'}Implements bus driving scenario logic: route following, bus stop detection, door/kneel requirements, passenger simulation, scoring (damage, smoothness, stop accuracy), and ground marker navigation.
Internal State
| Field | Type | Description |
|---|---|---|
M.enabledLineDebug | varies | Assigned as false |
Public API
| Function | Signature | Description |
|---|---|---|
M.onRaceStart | () | Initializes bus line, markers, nav helpers, unfreezes player |
M.onBeamNGTrigger | (data) | Handles bus stop enter/exit triggers |
M.onBusUpdate | (state) | Processes stop approach, timer countdown, door/kneel checks |
M.onPreRender | (dt, dtSim) | Updates markers, ground path, computes live ratings |
M.onVehicleSwitched | (oldId, newId, player) | Resets and reinitializes for new vehicle |
M.onScenarioRestarted | (scenario) | Resets state and reinitializes bus line |
M.onScenarioLoaded | (scenario) | Configures seat ballast and traffic |
M.onExtensionUnloaded | () | Clears markers and ground path, unfreezes player |
M.fail | (reason) | Fails the scenario with a message |
M.requestState | () | Sends current bus route state to UI |
M.onPhysicsPaused | () | Pauses stop timer |
M.onPhysicsUnpaused | () | Resumes stop timer |
M.onClientEndMission | () | Clears marker references |
M.onRaceResult | (final) | - |
Dependencies
scenario_scenarios, core_groundMarkers
Scoring System
| Metric | Calculation | Rating |
|---|---|---|
| Damage | Binary per-stop: any damage increase = 100% penalty | 0–100 per stop |
| Smoothness | Lateral acceleration + jerk, temporally smoothed | 0–100 per stop |
| Stop Distance | Longitudinal offset from bus stop center | 0–100 via smoothstep |
| Stop Angle | Dot product of bus forward vs stop forward direction | 0–100 via power curve |
How It Works
- Route setup: Loads bus line config from scenario JSON via
core_busRouteManager.setLine - Navigation: Sets ground markers path to next stop using nav helper waypoints
- Stop detection:
onBeamNGTriggerdetects enter/exit of bus stop triggers - Stop sequence: Vehicle must stop, kneel, open doors, wait 5 seconds, close doors, raise
- Camera: Switches between rider/external cameras during stop sequence
- Markers: Four corner markers (TSStatic) placed around each bus stop, color-coded red→green
- Scoring: Real-time smoothness/damage/position tracking per stop, aggregated at finish
Bus Stop Flow
Enter trigger → Stop moving → Kneel → Open doors → Wait 5s → Close doors → Raise → Exit trigger
↓
Next stop / SuccessKey Notes
- Strict mode requires sequential stop visits - skipping a stop fails the scenario
- Bus stats display is temporarily disabled (issue #2783)
- Uses
core_groundMarkersfor GPS-style navigation path - Player vehicle is frozen on reset and unfrozen on race start
- Supports passenger simulation via seat ballast parts and traffic spawning
Additional Exports
M.onVehicleStoppedMoving- (undocumented)
See Also
- Scenario Damage Goal - Damage-Based Win/Fail Condition - Related reference
- Scenario Demolition Derby - Last Vehicle Moving Wins - Related reference
- Scenario Distance Goal - Distance-Based Win/Fail Condition - Related reference
- Scenario System Guide - Guide
Offscreen View Demo
A minimal example extension demonstrating how to create and display an offscreen render view in an ImGui window. The camera orbits the origin.
Damage Goal
A scenario goal that monitors vehicle damage and triggers win or fail when damage exceeds a configurable limit. Supports threshold-based progress notifications.