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 Dealer

Vehicle and item stock management for campaign dealer/vendor locations. Tracks purchasable inventory with add/remove/buy operations and campaign save/resume support.

Vehicle and item stock management for campaign dealer/vendor locations. Tracks purchasable inventory with add/remove/buy operations and campaign save/resume support.


Overview

Maintains a stock inventory keyed by item type (e.g., $$$_VEHICLES). Supports both table-based items (vehicles with model/config) and numeric items (currency). Integrates with the campaign save system for persistence.


Public API

FunctionArgsReturnsDescription
M.addToStockitemType, valueObj-Adds an item to stock (table) or increments count (number)
M.getStockitemTypetableReturns a deep copy of stock for the given item type
M.removeFromStockitemType, valueObj-Removes a matching item from stock or decrements count
M.buyitemType, index-Purchase stub (not implemented)
M.onSerialize-tableReturns deep copy of dealer state
M.onDeserializeddata-Logs deserialization (state not restored here)
M.onSaveCampaignsaveCallback-Provides dealer state for campaign save
M.onResumeCampaigncampaignInProgress, data-Restores dealer state from save data

Stock Structure

M.state.stock = {
  ["$$$_VEHICLES"] = {
    { model = "pickup", config = "configs/pickup_stock.pc" },
    { model = "coupe", config = "configs/coupe_sport.pc" }
  },
  ["$$$_MONEY"] = 5000  -- Numeric stock type
}

Item Operations

-- Add a vehicle to dealer stock
campaign_dealer.addToStock("$$$_VEHICLES", { model = "pickup", config = "stock.pc" })

-- Get available vehicles (returns deep copy)
local vehicles = campaign_dealer.getStock("$$$_VEHICLES")

-- Remove after purchase
campaign_dealer.removeFromStock("$$$_VEHICLES", { model = "pickup", config = "stock.pc" })

-- Numeric items
campaign_dealer.addToStock("$$$_MONEY", 1000)
campaign_dealer.removeFromStock("$$$_MONEY", 500)

Duplicate Detection

For table items, existItem checks if an identical entry already exists by comparing all key-value pairs:

-- Will not add duplicate if model+config already in stock
campaign_dealer.addToStock("$$$_VEHICLES", { model = "pickup", config = "stock.pc" })

Notes

  • Item type keys are uppercased internally (string.upper)
  • The buy function is a stub - purchase logic is handled in campaign_exploration.uiEventSelectVehicle
  • Table items are matched by model + config for removal
  • Stock persists across campaign saves via onSaveCampaign / onResumeCampaign
  • Uses deepcopy for serialization to prevent reference issues
  • goto continue pattern is used for early loop exit

See Also

  • Campaign System - Overall campaign orchestration
  • Campaign Exploration - Vendor/garage UI integration

Campaign Comics

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

Campaign Exploration

Free-roam exploration mode between campaign scenarios. Manages trigger zones, location markers, road navigation, minimap UI, vehicle spawning, and transitions between exploration and scenarios.

On this page

OverviewPublic APIStock StructureItem OperationsDuplicate DetectionNotesSee Also