RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Vehicle Control from GEVE Architecture Quick ReferenceVehicle Scripting PatternsVehicle Lua Cheat Sheet62 Vehicle Scripting RecipesVehicle Modding GuideUnderstanding Vehicle Damage Systems

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

GuidesVehicle

VE Architecture Quick Reference

10-second refresher on Vehicle Engine core rules — lifecycle hooks, override patterns, and the no-ghost-values rule.

A 10-second refresher on VE (Vehicle Engine) core rules. Read this before any coding.


1. Extension Lifecycle (When Code Runs)

HookTimingUse For
onInitVehicle bootSetup vars, load modules, one-time init
onVehicleLoadedAfter physics readyTimers, logic needing physical body
updateGFX(dt)Every frame (GFX rate)UI updates, visual changes, input
onPhysicsStep(dt)2000Hz (if enabled)Torque, forces, actuators
onResetUser presses 'R'Clean state, stop timers/modes
onDespawnObjectBefore removalFinal cleanup, save data to GE

Enable physics step: obj:setPhysicsStepEnabled(true)


2. Hook System (How to Extend)

Core Principle: Hook > Override

Always prefer hooks over function overrides. Hooks chain; overrides replace.

-- GOOD: Hook pattern (chains with other mods)
local function onInit()
    -- Your init logic
end
M.onInit = onInit

-- AVOID: Direct overrides unless absolutely necessary
-- someModule.func = function() ... end  -- Breaks other mods!

Safe Override Pattern (When You Must)

Always call original FIRST to let game logic finish, then apply your changes.

local orgFunc = target.func
target.func = function(...)
    local res = orgFunc(...)  -- Game does its work FIRST
    -- Your mod logic here (won't be overwritten)
    return res
end

3. No Ghost Values (Keep Physics & UI in Sync)

Rule: If you change physics, you MUST update the UI/reporters.

A "Ghost Value" = physics changed but UI shows old data. Confusing UX!

Example: Torque Curve Modification

-- After modifying torqueCurve, update derived data
eng.torqueCurve[rpm] = torque * 1.2
eng.torqueData = eng:getTorqueData()  -- Sync UI!
eng.maxTorque = eng.torqueData.maxTorque
eng.maxPower = eng.torqueData.maxPower

Example: Safe getTorqueData Override

local orgGetTorqueData = eng.getTorqueData
eng.getTorqueData = function(device)
    local data = orgGetTorqueData(device)  -- Get base data FIRST
    -- Modify returned data for UI visibility
    data.maxTorque = data.maxTorque * multiplier
    return data
end

4. Architectural > Hacks

Do ThisAvoid This
Modify torqueCurve in onInit for permanent boostsUsing outputTorqueState in a loop when curve mod works
Use onPhysicsStep for 2000Hz physics forcesRunning physics in updateGFX
Use updateGFX for UI/visual updatesHeavy physics calcs in updateGFX
Namespace your electrics: myMod_valueGeneric names that collide: customValue

5. Quick Discovery

powertrain.getDevice("mainEngine")  -- Engine object
electrics.values                      -- Shared data bus
v.data.variables                      -- JBeam config values
extensions.hook("onReset")           -- Trigger all reset hooks

Summary Checklist

  • Hook into lifecycle at the right timing
  • Prefer hooks over overrides
  • Call original first when overriding
  • Update UI/reporters when changing physics
  • Namespace your electrics to avoid collisions

Vehicle Control from GE

How to find, spawn, switch, and send commands to vehicles from Game Engine Lua — the essential operations for any gameplay mod.

Vehicle Scripting Patterns

Proven patterns for vehicle development — impact detection, speed-based logic, damage monitoring, cross-module communication, and throttled updates.

On this page

1. Extension Lifecycle (When Code Runs)2. Hook System (How to Extend)Core Principle: Hook > OverrideSafe Override Pattern (When You Must)3. No Ghost Values (Keep Physics & UI in Sync)Example: Torque Curve ModificationExample: Safe getTorqueData Override4. Architectural > Hacks5. Quick DiscoverySummary Checklist