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 Loader

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

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


Overview

Loads campaign JSON files from /campaigns/, validates their structure, manages save files in /saves/campaigns/, and orchestrates the start/resume flow including extension loading.


Public API

FunctionArgsReturnsDescription
M.getCampaignFilenames-tableScans /campaigns/ for JSON files with campaign header type
M.getList-tableLoads and returns all campaign entries
M.getCampaignScenarios-tableReturns cached list of all campaign scenario paths
M.loadCampaigncampaignfiletableLoads a single campaign JSON, adds metadata (mod info, previews)
M.startnewCampaign, [endCallback]-Full campaign start: unloads level, loads extensions, starts/resumes
M.startByFolderpath, [endCallback]-Starts a campaign by its source folder path
M.splitFieldByTokenfield, tokentableSplits a dotted string (e.g., "sub.loc") into parts
M.checkSaveExiststitle, savesEnabledstring/nilChecks if a save file exists for the given campaign title
M.saveCampaigncampaign-Saves campaign state to JSON if saves are enabled
M.resumeSavedCampaigncampaign, saveFilename-Resumes a campaign from a save file
M.onInit--Initialization hook (referenced but not defined in source)

Internal State

FieldTypeDescription

Campaign Modules

The loader loads these extensions as a group:

M.campaignModules = {
  'campaign_campaigns',
  'campaign_exploration',
  'campaign_comics',
  'campaign_rewards',
  'campaign_dealer',
  'campaign_photoSafari'
}

Campaign File Structure

{
  "header": { "type": "campaign" },
  "meta": {
    "title": "My Campaign",
    "startingLocation": "section1.mission1",
    "subsections": {
      "section1": {
        "locations": {
          "mission1": {
            "path": "/path/to/scenario.json",
            "info": { "title": "...", "type": "race", "subtype": "timeTrial" },
            "onEvent": { "onSucceed": {...}, "onFail": {...} }
          }
        },
        "triggers": ["/path/to/prefab.prefab"]
      }
    }
  }
}

Save System

FunctionDescription
saveCampaignHooks all modules via onSaveCampaign, writes to /saves/campaigns/slotN.json
resumeSavedCampaignReads save, calls onResumeCampaign on each module, then resumes campaign
checkSaveExistsScans save directory for matching campaign title

Save file header: { version: 1, type: "campaignSave", title: "..." }


Validation

The validate function ensures:

  • Campaign has a title (defaults to <missing title>)
  • Subsections have locations tables
  • Locations have info with title, type, typeName
  • Location types are split into type and subtype (e.g., "race.timeTrial")
  • disableEndUI requires exactly 1 entry in endOptions

Start Flow

  1. If a level is loaded (MissionGroup exists), delays start until unloaded
  2. Unloads auto extensions, loads preset + scenario + campaign modules
  3. Processes campaign structure via processCampaignStartInternal
  4. Checks for existing save file → resume or fresh start
  5. Calls campaign_campaigns.startCampaign() or resumeSavedCampaign()

Notes

  • Campaign metadata includes mod info via core_modmanager.getModFromPath()
  • Preview images are auto-discovered from the campaign source folder
  • Official content is detected via isOfficialContentVPath()
  • The triggerDelayedStart pattern handles async level unloading

See Also

  • Campaign System - Core campaign orchestration
  • Campaign Exploration - Free-roam exploration mode

Additional Exports

  • M.saveDataTable - (undocumented)
  • M.triggerDelayedStart - (undocumented)

Campaign System

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

Campaign Comics

Comic/cutscene playback system for campaign narrative sequences. Displays Spine-animated comic panels with background audio between campaign scenarios.

On this page

OverviewPublic APIInternal StateCampaign ModulesCampaign File StructureSave SystemValidationStart FlowNotesSee AlsoAdditional Exports