RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

server/commands - Camera & Input Commandsge_utils - Game Engine Utility Functionsmain.lua - GE Lua Entry Point & Game Loopmap.lua - Navigation Graph (AI Road Map)screenshot.lua - Screenshot Systemserver/server - Level Loading & Game ServerserverConnection - Client-Server Connection Manager`setSpawnpoint` - Default Spawn Point Persistence`simTimeAuthority` - Simulation Time & Bullet Time Control`spawn` - Vehicle Spawning & Safe Placement`suspensionFrequencyTester` - Suspension Natural Frequency Analysis
Auto AnnotationBoosterCalibrate ESCCompile ImpostersCompile MeshesConfig List GeneratorDecal Roads EditorDependency TreeDoc CreatorExport (glTF)Follow The White RabbitForest GeneratorGround Model DebugInput System UtilsInstanced Line Render DemoJBeam StatsLog StreamsMap TilesNode Beam ExportNode StreamPhotomodePrecompile ShadersPrecompile VehiclesProcedural Track (Gymkhana Generator)Rectangle GeneratorRender Components APIResave MaterialsRich PresenceSave Dynamic DataScreenshot Creator (Vehicle Thumbnails)ShowroomSort LinesStep HandlerTerrain GeneratorTest Extension ProxiesTest JSON Files Syntaxutil/vehicleRopeDebug - Rope Physics Debug UIutil/worker - Batch Job Workerutil/wsTest - WebSocket Test Server

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 Extensionsutil

Step Handler

A sequential step-execution system for orchestrating multi-step gameplay sequences (fades, vehicle spawns, level loads, waits, traffic).

A sequential step-execution system for orchestrating multi-step gameplay sequences (fades, vehicle spawns, level loads, waits, traffic).


Overview

util_stepHandler provides a declarative pipeline where you define an array of steps, each with a processTask function. Steps execute sequentially in onUpdate, advancing when step.complete = true. Built-in step factories handle common tasks: screen fades, waits, vehicle spawning, traffic spawning, and level loading.

Extension path: lua/ge/extensions/util/stepHandler.lua


Exports (M)

Core

FunctionSignatureDescription
startStepSequence(steps, callback?)Begins executing the step array. Optional callback runs after the last step.
skipToLastStepOrCallback()Jumps to the final step (usually the callback).
M.taskSpawnTrafficStep(step)-
M.taskLoadLevelStep(step)-

Step Factories

FunctionSignatureDescription
makeStepFadeToBlack(duration?)Creates a fade-to-black step.
makeStepFadeFromBlack(duration?)Creates a fade-from-black step.
makeStepWait(seconds)Creates a timed wait step.
makeStepReturnTrueFunction(fn)Creates a step that completes when fn(step, dtTable) returns true.
makeUiMessageStep(message)Creates a step that shows a UI message and completes immediately.
makeStepSpawnVehicle(options, callback?)Spawns a vehicle; completes when it's ready. Callback receives (step, vehId).
makeStepSpawnVehicleSimple(model, config, callback?)Simplified vehicle spawn step.
makeStepSpawnTrafficSimple(amount, active, generator?)Spawns traffic vehicles and activates traffic system.
makeLoadLevelStep(level)Loads a level; completes on onClientStartMission.

Event Hooks

FunctionSignatureDescription
onUpdate(dtReal, dtSim, dtRaw)Processes the current step each frame.
onScreenFadeState(state)Handles fade completion callbacks.
onClientStartMission(state)Marks level-load steps as complete.
onVehicleGroupSpawned(vehIds, groupId)Handles traffic group spawn completion.

Internals

Step Structure

Each step is a table with:

  • name - descriptive string
  • processTask(step, dtTable) - called each frame; set step.complete = true to advance
  • timeout - max seconds before auto-complete (default 120)
  • origin - debug traceback of creation site

Task Data

taskData holds:

  • steps - the step array
  • currentStep - 1-based index
  • active - boolean
  • data - shared data between steps

Timeout

If a step exceeds its timeout, it's force-completed with an error log.

Debug Window

Set showDebugWindow = true to show an ImGui window listing all steps and their states.


How It Works

  1. Define steps using the factory functions.
  2. Call startStepSequence(steps, callback).
  3. Each frame, onUpdate calls the current step's processTask.
  4. When step.complete = true, the next step begins.
  5. After all steps, taskData.active becomes false.

Lua Examples

local stepper = extensions.util_stepHandler

-- Multi-step sequence: fade out → spawn vehicle → fade in
stepper.startStepSequence({
  stepper.makeStepFadeToBlack(0.5),
  stepper.makeStepSpawnVehicleSimple("pickup", "vehicles/pickup/d15_4wd_A.pc", function(step, vehId)
    print("Spawned vehicle: " .. vehId)
  end),
  stepper.makeStepFadeFromBlack(0.5),
}, function()
  print("Sequence complete!")
end)

-- Wait step
stepper.startStepSequence({
  stepper.makeStepWait(3),
  stepper.makeStepReturnTrueFunction(function()
    print("Done waiting!")
    return true
  end),
})

-- Load a level then spawn traffic
stepper.startStepSequence({
  stepper.makeLoadLevelStep("east_coast_usa"),
  stepper.makeStepSpawnTrafficSimple(10, 5),
})

Additional Exports

  • M.makeLoadLevelStep - (undocumented)
  • M.makeStepFadeFromBlack - (undocumented)
  • M.makeStepFadeToBlack - (undocumented)
  • M.makeStepReturnTrueFunction - (undocumented)
  • M.makeStepSpawnTrafficSimple - (undocumented)
  • M.makeStepSpawnVehicle - (undocumented)
  • M.makeStepSpawnVehicleSimple - (undocumented)
  • M.makeStepWait - (undocumented)
  • M.makeUiMessageStep - (undocumented)
  • M.onClientStartMission - (undocumented)
  • M.onScreenFadeState - (undocumented)
  • M.onUpdate - (undocumented)
  • M.onVehicleGroupSpawned - (undocumented)
  • M.skipToLastStepOrCallback - (undocumented)
  • M.startStepSequence - (undocumented)

Sort Lines

Sorts JSONL (one-JSON-per-line) files alphabetically by their `name` field, primarily used for audio definition files.

Terrain Generator

Creates terrain blocks from heightmap arrays, PNG files, or project directories with full material support.

On this page

OverviewExports (M)CoreStep FactoriesEvent HooksInternalsStep StructureTask DataTimeoutDebug WindowHow It WorksLua ExamplesAdditional Exports