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
Campaign SystemCampaign LoaderCampaign ComicsCampaign DealerCampaign ExplorationCampaign Photo SafariCampaign Rewards

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 Extensionscampaign

Campaign System

Core campaign orchestration module. Manages campaign lifecycle, scenario sequencing, location status tracking, rewards, achievements, and UI flow between campaign scenarios and exploration.

Core campaign orchestration module. Manages campaign lifecycle, scenario sequencing, location status tracking, rewards, achievements, and UI flow between campaign scenarios and exploration.


Dependencies

M.dependencies = {'scenario_scenarios'}

Overview

Depends on scenario_scenarios. Tracks a single active campaign with subsections containing scenario locations. Handles scenario start/finish events, reward selection, end-screen UI, save/resume, and exploration transitions.


Public API

FunctionArgsReturnsDescription
M.startCampaignnewCampaign-Starts a processed campaign from its starting location
M.stop--Stops the active campaign and cleans up
M.getCampaign-table/nilReturns the active campaign object
M.getCampaignActive-booleanWhether a campaign is currently active
M.getCampaignTitle-string/nilTitle of the active campaign
M.getCurrentLocation-string/nilCurrent subsection.location key
M.startScenarioFromKeykey, [scenario]-Loads and executes a scenario by location key
M.canStartScenarioscenarioKeybooleanChecks if all requirements (scenarios, vehicles) are met
M.isLocationCompletedlocationKeybooleanWhether the location has been completed
M.canImproveResultlocationKeybooleanWhether the location medal can be improved (not gold)
M.markCompletedsubsection, locationKey-Marks a location as completed
M.isCampaignOverscenariobooleanWhether the campaign has no more scenarios
M.getSubsectionsubsectionKeytable/nilGets subsection data by key
M.getActiveSubsection-table/nilGets the currently active subsection
M.getLocationDatasubsectionKey, locationKeytable/nilGets location data from a specific subsection
M.getActiveSubsectionLocationDatalocationKeytable/nilGets location data from the active subsection
M.getOwningSubsectionlocationKeytable/nilFinds which subsection owns a location
M.isSubsectionMarkersubsectionKey, markerNamebooleanChecks if a marker belongs to a subsection
M.isTransitionPointsubsectionKey, locationKeybooleanWhether location is a transition point
M.isMissionGiversubsectionKey, locationKeybooleanWhether location is a mission giver
M.isPlayerHQsubsectionKey, locationKeybooleanWhether location is player HQ
M.isSiteLocationsubsectionKey, locationKeybooleanWhether location is a site (non-race)
M.isScenarioLocationsubsectionKey, locationKeybooleanWhether location is a playable scenario
M.scenarioStartedscenario-Hook: processes intro events and increments attempts
M.scenarioFinishedscenario-Hook: processes results, rewards, achievements, end UI
M.uiEventNext--UI callback: advance to next scenario
M.uiEventCancel--UI callback: cancel and return to exploration
M.execEndCallback--Executes the campaign end callback
M.rewardSelectionCallbackitemIndex-Processes player's reward choice
M.resumeCampaigncampaignInProgress, data-Resumes a campaign from saved state
M.getLocationStatusTable-tableReturns the location status tracking table
M.onSerialize-tableSerializes campaign state
M.onDeserializeddata-Stub for deserialization
M.onExtensionUnloaded--Stops campaign on unload
M.onScenarioChangescenario-Unloads extension if no campaign is active
M.onSaveCampaignsaveCallback-Provides campaign state for save system
M.onResetGameplayplayerID-Resets vehicle during exploration

Campaign State Structure

campaign = {
  meta = {
    title = "Campaign Name",
    subsections = { [key] = { locations = {...}, triggers = {...}, level = "..." } },
    startingLocation = "subsection.location",
    defaultVehicle = { model = "...", config = "...", color = "..." },
    sourceFile = "path/to/campaign.json"
  },
  state = {
    campaignActive = true,
    currentLocation = "subsection.location",
    activeSubsection = "subsectionKey",
    scenarioKey = "locationKey",
    scenarioExecutionOrder = {"scenario1", "scenario2"},
    locationStatus = { ["sub.loc"] = {attempts = 0, state = "ready", medal = ""} },
    selectedRewardIndex = nil
  }
}

Location Status Values

StateDescription
readyNot yet attempted
completedSuccessfully finished
failedLast attempt failed

Notes

  • Campaigns are mutually exclusive - starting a new one stops the current
  • Scenario flow: startScenarioFromKey → scenarioStarted → scenarioFinished → processNextScenario
  • End screen buttons are dynamically built based on endOptions in location data
  • Comics can play between scenarios via campaign_comics
  • Achievements are unlocked via OnlineServiceProvider.unlockAchievement()
  • The whiteListActions default is "default_whitelist_campaign"

See Also

  • Campaigns Loader - Campaign file loading and save management
  • Campaign Exploration - Free-roam between scenarios
  • Campaign Comics - Comic cutscene playback
  • Campaign Dealer - Vehicle stock management

C2 Vehicle Manager

Real-time vehicle data streaming plugin for the C2 WebSocket system. Subscribers receive position, rotation, and velocity updates each frame.

Campaign Loader

Campaign file loading, validation, save management, and campaign start orchestration. Handles the full lifecycle from JSON file to running campaign.

On this page

DependenciesOverviewPublic APICampaign State StructureLocation Status ValuesNotesSee Also