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

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

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


Internal State

FieldTypeDescription
M.instancesvariesAssigned as {}

Public API (Exports)

FunctionSignatureDescription
M.init(scenario)Parses and validates speed goals from scenario JSON
M.processState(scenario, state, stateData)Checks speed each race tick
M.updateFinalStatus(scenario, instance)Reports final goal status to statistics

Goal JSON Schema

{
  "goal": {
    "speed": {
      "minSpeed": 10,
      "maxSpeed": 50,
      "maxTimeout": 5,
      "delay": 3,
      "purpose": "fail",
      "wayPointNum": [3, 5, 8],
      "msg": "scenarios.myScenario.tooSlow"
    }
  }
}
FieldTypeDefaultDescription
minSpeednumberoptionalMinimum speed (m/s) - triggers timeout if below
maxSpeednumberoptionalMaximum speed (m/s) - triggers timeout if above
maxTimeoutnumber0Seconds outside range before triggering result
delaynumberoptionalSeconds after race start before checking begins
purposestring"fail""fail" or "win"
wayPointNumnumber[]optionalOnly check speed at these waypoint indices
msgstringautoCustom message on trigger

How It Works

  1. init filters goals for id == "speed", validates types, defaults purpose to "fail"
  2. Each onRaceTick (0.25s interval):
    • If delay is set and timer hasn't passed it, skips check
    • If wayPointNum is set, only checks at those specific waypoint indices
    • Reads vehicle velocity from map.objects via fobjData.vel:length()
  3. If speed is outside [minSpeed, maxSpeed] range:
    • Increments instance.Timeout by tick time
    • Shows countdown flash messages each second
  4. If speed returns to valid range, resets timeout to 0
  5. When timeout exceeds maxTimeout, calls showMsg which:
    • Sets result to "failed" or "passed" based on purpose
    • Calls scenario_scenarios.finish() with formatted time string

Usage Examples

-- In scenario JSON: fail if speed drops below 15 m/s for 5 seconds
{
  "vehicles": {
    "scenario_player0": {
      "goal": {
        "speed": {
          "minSpeed": 15,
          "maxTimeout": 5,
          "purpose": "fail"
        }
      }
    }
  }
}

-- Check speed only at waypoints 2 and 4:
{
  "speed": {
    "maxSpeed": 30,
    "maxTimeout": 3,
    "wayPointNum": [2, 4],
    "purpose": "fail"
  }
}

Key Notes

  • maxSpeed of 0 is explicitly rejected (logged as error)
  • Speed is measured in m/s from the map object tracker
  • If map tracking is missing, re-enables it via mapmgr.enableTracking
  • Countdown messages use helper.flashUiMessage with 0.5s duration
  • The win purpose is useful for speed challenge scenarios
  • Timeout resets completely when speed returns to valid range

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

Scenarios Loader

M.dependencies = {'core_levels'}

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.

On this page

Internal StatePublic API (Exports)Goal JSON SchemaHow It WorksUsage ExamplesKey NotesSee Also