RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

GE Extension SystemGE Architecture Quick ReferenceGE Boot SequenceGE Cross-VM CommunicationHow Mods Are LoadedInter-VM Communication (GE ↔ VE ↔ UI)Vehicle Boot Sequence & Lifecycle

Reference

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

GuidesArchitecture

Vehicle Boot Sequence & Lifecycle

The exact order in which vehicle systems initialize — from JBeam compilation to physics loops. Essential for timing your VE code correctly.

Understanding the order in which the vehicle environment boots is critical for ensuring your code runs at the right time. Getting the timing wrong means your extension tries to read data that doesn't exist yet, or misses the window to configure systems before they start running.

:::tip[Quick Rule] Use onInit for setup, onVehicleLoaded for anything that needs the physical vehicle, and updateGFX for per-frame logic. :::

1. The Boot Sequence (Startup)

When a vehicle is spawned or the Lua VM is reloaded:

  1. Environment Setup: main.lua sets up global constants (vmType, package.path).
  2. Core Initialization: init() in main.lua is called.
    • Raw JBeam is loaded and compiled into v.data.
    • Core modules (electrics, powertrain, wheels, beamstate) are required.
  3. initSystems():
    • Stage 1: electrics.init(), damageTracker.init(), beamstate.init().
    • Stage 2: powertrain.init(), controller.init().
    • Stage 3: sounds.init(), props.init(), fire.init().
  4. Extension Hooks: extensions.hook("onInit") is called for all loaded extensions.
  5. Post-Spawn: extensions.hook("onVehicleLoaded") is called. The vehicle is now physically in the world.

2. The Frame Loop (Runtime)

Every frame (Graphics Step):

  1. sensors.updateGFX()
  2. input.updateGFX()
  3. electrics.updateGFX()
  4. extensions.hook("updateGFX") -- Your extension logic usually goes here.
  5. powertrain.updateGFX()
  6. guihooks.sendStreams() -- Data sent to UI.
  7. props.updateGFX() -- Needle/prop movement.

3. The Physics Loop (High-Frequency)

Only runs if a module requests it via obj:setPhysicsStepEnabled(true). Runs at 2000Hz.

  1. powertrain.update()
  2. controller.update()
  3. extensions.hook("onPhysicsStep")

4. Reset Sequence (Pressing 'R')

When the user resets the vehicle:

  1. onVehicleReset() is called in main.lua.
  2. guihooks.reset().
  3. extensions.hook("onReset").
  4. Every core module's .reset() function is called (e.g., electrics.reset(), powertrain.reset()).

Key Hooks for Developers

HookTimingPurpose
onInitDuring bootSetup variables, load dependent modules.
onVehicleLoadedAfter physics initStart logic that requires a physical object (like timers).
updateGFX(dt)Every frameMain logic, UI updates, visual changes.
onPhysicsStep(dt)2000HzLow-level torque/force/actuator control.
onResetDuring resetClean up state, stop active timers/modes.
onDespawnObjectBefore removalFinal cleanup, saving data to GE.

Inter-VM Communication (GE ↔ VE ↔ UI)

Complete guide to cross-VM communication — GE to VE commands, VE to GE callbacks, peer vehicle messaging, UI events, and the electrics data bus.

Lua Classes & Metatables

When and how to use Lua classes in BeamNG modding — metatables, constructors, inheritance, with real examples like parcels, checkpoints, and NPC fleets.

On this page

1. The Boot Sequence (Startup)2. The Frame Loop (Runtime)3. The Physics Loop (High-Frequency)4. Reset Sequence (Pressing 'R')Key Hooks for Developers