RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Gameplay AchievementGameplay CityDiscoverForce FieldGarage ModeMarker InteractionParking SystemGameplay Playmode MarkersGameplay PoliceGameplay RallyGameplay Rally LoopGameplay Raw POIsGameplay Skidpad TestSpeed Trap LeaderboardsSpeed Traps and CamerasGameplay StatisticsTaxi Ride SystemTraffic SystemVehicle PerformanceWalking
Locations DetectorMission ManagerMissionsMission Screen UIPOI TestProgressMission Start TriggerUnlocks

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 Extensionsgameplaymissions

Mission Manager

Reference for `gameplay_missions_missionManager`, the central orchestrator for starting and stopping missions with multi-step task pipelines.

Reference for gameplay_missions_missionManager, the central orchestrator for starting and stopping missions with multi-step task pipelines.


Module Exports (M)

FunctionSignatureDescription
start / startWithFade(mission, userSettings, startingOptions)Start mission with fade-to-black loading screen
startAsScenario(mission, userSettings)Start without fade (scenario-style)
startFromWithinMission(mission, userSettings, instant)Transition from one mission to another
startInstant(mission, userSettings, startingOptions)Start immediately without fade or stashing
startWithLoadingLevel(mission, userSettings, level)Load a level first, then start
stop(mission, data)Stop mission (with optional fade)
attemptAbandonMissionWithFade(mission, force, abandonButtonPressed)Abandon with fade and cleanup
getForegroundMissionId() → string|nilReturns the currently active foreground mission ID
getCurrentTaskdataTypeOrNil() → string|nilReturns "start" or "stop" if a task is active
stopForegroundMissionInstantly()Emergency stop without cleanup pipeline
fadeDuration0.75Duration of fade transitions
allowMissionInteraction() → boolReturns false if game state is not freeroam

Hooks / Lifecycle

FunctionDescription
onUpdateMain loop: processes task pipeline steps, runs ongoing missions
onTrafficStartedCompletes traffic spawn step in task pipeline
onParkingVehiclesActivatedCompletes traffic step when only parking spawns
onScreenFadeStateHandles fade screen state transitions for task pipeline
onClientEndMissionAlias for stopForegroundMissionInstantly (level unload)
onCareerActiveAlias for stopForegroundMissionInstantly

Task Pipeline Architecture

The manager uses a step-based task pipeline (taskData) that processes sequentially each frame:

Start Pipeline (startWithFade)

  1. taskStartFadeStep - Fade screen to black (timeout: 10s)
  2. taskStartRemoveVehicles - Delete all vehicles (if removeAllVehiclesBeforeMission)
  3. taskStartPreMissionHandling - Process user settings, save starting info, freeze traffic, prepare vehicle stash, load custom script
  4. taskStartVehicleStep - Spawn or select player vehicle, set differentials
  5. taskStartStartingOptionRepairStep - Handle repair costs in career mode
  6. taskStartTakePartConditionSnapshot - Snapshot vehicle part conditions
  7. taskStartTrafficStep - Spawn or activate traffic/parking
  8. taskStartMissionStep - Call mission:onStart(), set environment, stash vehicles

Stop Pipeline

  1. taskStopMissionStep - Call mission:onStop(), restore environment/traffic/vehicles/camera
  2. taskStartRemoveVehicles - Delete vehicles if needed
  3. taskStopRespawnVehicleStep - Respawn default vehicle
  4. taskStopRespawnTrafficStep - Restore traffic
  5. taskStopFadeStep - Fade back in, reset game state to freeroam

Internals

Vehicle Stashing

Before a mission, all existing vehicles are "stashed" (deactivated). After the mission, they are "unstashed" (reactivated and unfrozen).

Traffic Management

  • Freezes current traffic state before mission
  • Spawns new traffic per mission's setupModules.traffic configuration
  • Restores previous traffic state on stop

Environment Setup

  • Saves and restores time-of-day, fog density
  • Applies mission-specific time, time scale, fog, and wind settings

Foreground Exclusivity

Only one non-background mission runs at a time, tracked by foregroundMissionId.


How It Works

-- Each frame, onUpdate processes the active task pipeline:
local function onUpdate(dtReal, dtSim, dtRaw)
  if taskData.active then
    local step = taskData.steps[taskData.currentStep]
    while step do
      step.processTask(step, taskData)
      -- Timeout enforcement (default 120s)
      if step.complete then
        taskData.currentStep = taskData.currentStep + 1
        step = taskData.steps[taskData.currentStep]
      else
        step = nil -- wait for next frame
      end
    end
  end
  -- Run ongoing mission updates
  if foregroundMissionId then
    for _, mission in ipairs(gameplay_missions_missions.get()) do
      if mission._isOngoing then
        mission:onUpdate(dtReal, dtSim, dtRaw)
      end
    end
  end
end

Hooks Fired

HookWhen
onMissionStartWithFadeStart pipeline begins
onAnyMissionChanged("started", ...)Mission successfully started
onAnyMissionWillChange("stopped", ...)Before mission stop
onAnyMissionChanged("stopped", ...)After mission fully stopped
onMissionAbandonedWhen abandon pipeline begins
onMissionReconfiguredWhen restarting same mission with new settings
onMissionStoppedWhen stop pipeline begins
M.allowMissionInteraction()
M.attemptAbandonMissionWithFade(mission, force, abandonButtonPressed)
M.dependenciesvalue
M.fadeDurationvalue
M.getCurrentTaskdataTypeOrNil()
M.getForegroundMissionId()
M.onCareerActive()
M.onClientEndMissionvalue
M.onParkingVehiclesActivatedvalue
M.onScreenFadeState(state)
M.onTrafficStarted()
M.onUpdate(dtReal, dtSim, dtRaw)
M.start(mission, userSettings, startingOptions)
M.startAsScenario(mission, userSettings)
M.startFromWithinMission(mission, userSettings, instant)
M.startInstant(mission, userSettings, startingOptions)
M.startWithFade(mission, userSettings, startingOptions)
M.startWithLoadingLevel(mission, userSettings, level)
M.stop(mission, data)
M.stopForegroundMissionInstantly()

See Also

  • missions/locationsDetector - Nearby Mission Location Detection - Related reference
  • missions/missionScreen - Mission UI Screen & Starting Options - Related reference
  • missions/missions - Mission Registry & Data Management - Related reference
  • Gameplay Systems Guide - Guide

Locations Detector

Reference for `gameplay_missions_locationsDetector`, which detects missions near the player by checking clustered POI locations.

Missions

Reference for `gameplay_missions_missions`, the central registry that loads, constructs, caches, and serves all missions in the game. This is the primary entry point for accessing mission objects.

On this page

Module Exports (M)Hooks / LifecycleTask Pipeline ArchitectureStart Pipeline (startWithFade)Stop PipelineInternalsVehicle StashingTraffic ManagementEnvironment SetupForeground ExclusivityHow It WorksHooks FiredSee Also