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

Demolition Derby

A simple demolition derby scenario mode where the last vehicle still moving wins. Tracks all scenario vehicles and declares a winner when only one remains in motion.

A simple demolition derby scenario mode where the last vehicle still moving wins. Tracks all scenario vehicles and declares a winner when only one remains in motion.


Public API

FunctionSignatureDescription
M.onScenarioChange(sc)Initializes vehicle tracking when scenario enters "running" state
M.onPreRender(dt)Checks vehicle movement each second; declares winner

Internals

  • Tick interval: Checks once per second (accumulates dt until ≥ 1)
  • Movement threshold: Vehicle must move > 1 unit between ticks to count as "moving"
  • Stop ticks: After 15 consecutive stopped ticks, a vehicle is considered out
  • Win condition: Exactly 1 vehicle moving while all others are stopped

How It Works

  1. onScenarioChange detects when a scenario enters "running" state
  2. Iterates all scenario vehicles, stores references and initial positions
  3. onPreRender runs every second:
    • For each vehicle, checks distance from last known position
    • Moving vehicles (>1 unit) reset their stop counter
    • Stationary vehicles increment stop counter
    • Vehicles with >15 stop ticks are considered "stopped"
  4. If exactly 1 vehicle is moving and all others are stopped, that vehicle wins
  5. Calls scenario_scenarios.finish({msg = winnerName..' WINS!!!'})"

Usage Examples

-- Demolition derby is activated by including it in scenario modules
-- The scenario JSON should define multiple vehicles:
{
  "vehicles": {
    "scenario_player0": { "driver": {"player": true} },
    "ai_vehicle_1": { "driver": {"AI": true} },
    "ai_vehicle_2": { "driver": {"AI": true} }
  }
}

Key Notes

  • Simple position-based movement detection (not velocity-based)
  • No damage tracking - purely based on whether vehicles are still moving
  • The 15-second stop timeout prevents false positives from brief stops
  • All vehicle tracking resets when scenario state changes
  • Works with any number of vehicles (2+)

See Also

  • Scenario Bus Driver - Bus Route Scenario Logic - Related reference
  • Scenario Damage Goal - Damage-Based Win/Fail Condition - Related reference
  • Scenario Distance Goal - Distance-Based Win/Fail Condition - Related reference
  • Scenario System Guide - Guide

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.

Distance Goal

A scenario goal that monitors the distance between two vehicles and triggers win or fail when distance thresholds are exceeded.

On this page

Public APIInternalsHow It WorksUsage ExamplesKey NotesSee Also