API ReferenceGE Extensionsscenario
Time Limit Goal
A scenario goal that fails the scenario if the player exceeds a maximum time. Supports countdown warnings and wait time after the limit.
A scenario goal that fails the scenario if the player exceeds a maximum time. Supports countdown warnings and wait time after the limit.
Internal State
| Field | Type | Description |
|---|---|---|
M.instances | varies | Assigned as {} |
Public API (Exports)
| Function | Signature | Description |
|---|---|---|
M.init | (scenario) | Parses and validates timeLimit goals from scenario JSON |
M.processState | (scenario, state, stateData) | Checks time each tick; fails at limit |
M.updateFinalStatus | (scenario, instance) | Reports final goal status to statistics |
Goal JSON Schema
{
"goal": {
"timeLimit": {
"maxTime": 60,
"waitTime": 0,
"countdown": 10,
"msg": "scenarios.myScenario.timeFail"
}
}
}| Field | Type | Default | Description |
|---|---|---|---|
maxTime | number | required | Maximum allowed time in seconds |
waitTime | number | required | Grace period after maxTime before failing |
countdown | number | optional | Seconds before limit to start showing countdown |
msg | localizedString | auto | Custom failure message |
How It Works
initfilters goals forid == "timeLimit", validates thatmaxTimeandwaitTimeare numbers- Processing states:
onRaceTick: Ifcountdownis set and time remaining < countdown seconds, shows decreasing flash messages ("3", "2", "1")- After
maxTime + waitTimehas passed, callsfailedGoal()which sets status to"failed"and callsscenario_scenarios.finish() onRaceResult: IffinalTime > maxTime, also triggers failure
- Countdown tracking uses
instance.waitto prevent duplicate messages per second
Usage Examples
-- In scenario JSON: fail if race takes longer than 120 seconds
{
"vehicles": {
"scenario_player0": {
"goal": {
"timeLimit": {
"maxTime": 120,
"waitTime": 0
}
}
}
}
}
-- With 10-second countdown warning:
{
"timeLimit": {
"maxTime": 60,
"waitTime": 2,
"countdown": 10,
"msg": "Time's up!"
}
}Key Notes
- Both
maxTimeandwaitTimemust be numbers (validated ininit) - The actual fail triggers at
maxTime + waitTime, not justmaxTime countdownshows flash messages withhelper.flashUiMessageat each second- If countdown is not a number, the goal is rejected with an error log
- Also checks
onRaceResultfor post-race validation (e.g., if race finishes exactly at limit) - The
passedstatus is only set inonRaceResultwhenfinalTime <= maxTime
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
Speed Goal
A scenario goal that monitors vehicle speed and triggers win or fail if the vehicle stays outside a speed range for too long. Supports min/max speed, timeout countdown, waypoint-specific checks, and d
Waypoint Action
A scenario goal that displays flash messages when the player reaches specific waypoints. Unlike other goals, this is purely informational - it doesn't trigger win or fail conditions.