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

62 Vehicle Scripting Recipes

Copy-paste solutions for powertrain control, JBeam manipulation, input handling, UI communication, and niche modding tasks.

Numbered recipes for quick reference. Each one is a self-contained solution you can drop into your vehicle extension.

:::tip Use Ctrl+F to search by keyword (e.g., "turbo", "mass", "steering"). :::

1. Powertrain & Torque (#powertrain #torque #rpm)

  1. Add permanent torque boost (In onInit): for rpm, torque in pairs(eng.torqueCurve) do if type(rpm) == "number" then eng.torqueCurve[rpm] = torque * 1.2 end end; eng.torqueData = eng:getTorqueData()
  2. Find the main engine object: local eng = powertrain.getDevice("mainEngine")
  3. Check if clutch is slipping: local isSlipping = math.abs(eng.outputAV1 - gearbox.inputAV) > 1
  4. Force a specific gear: controller.mainController.shiftToGearIndex(2)
  5. Disable/Reset rev limiter: eng:resetTempRevLimiter()
  6. Calculate current Horsepower: local hp = (eng.combustionTorque * eng.outputAV1) / 745.7
  7. Stall/Lock engine: powertrain.getDevice("mainEngine"):lockUp()
  8. Check fuel level percentage: local fuel = electrics.values.fuel * 100
  9. Change idle RPM dynamically: eng.idleAVOverwrite = 800 * 0.104719755
  10. Detect when shifting starts: if electrics.values.isShifting then ... end
  11. Architectural Boost (UI Visible): Override getTorqueData to multiply curve values (see Modding Guide).
  12. Master Power Multiplier: eng.outputTorqueState = 0.5 (50% power)
  13. Get total wheel torque: local totalTorque = wheels.wheelTorque
  14. Check if engine is running: local running = not eng.isStalled and eng.outputAV1 > 0
  15. Apply braking torque to all wheels: wheels.scaleBrakeTorque(1.0)
  16. Get turbo boost pressure: local boost = electrics.values.turboBoost or 0
  17. Check if NOS is active: local nos = electrics.values.n2oActive or false

2. JBeam & Physics (#physics #jbeam #pos #force)

  1. Get JBeam variable value: local myVar = v.data.variables["$myVar"]
  2. Change beam spring/damp at runtime: obj:setBeam(cid, id1, id2, strength, spring, damp)
  3. Find node CID by name: local nodeId = beamstate.nodeNameMap["nodeName"]
  4. Get node world position: local pos = obj:getNodePosition(nodeId)
  5. Add mass to a node: obj:setNodeMass(nodeId, newMass)
  6. Check if a part is broken (via DamageTracker): local isBroken = damageTracker.getDamage("body", "hood")
  7. Break a group of beams: beamstate.breakBreakGroup("groupName")
  8. Get distance between two nodes: local dist = obj:getNodePosition(id1):distance(obj:getNodePosition(id2))
  9. Apply a force vector to a node: obj:applyForceVector(nodeId, vec3(0, 5000, 0))
  10. Get vehicle world rotation (Quat): local rot = obj:getRotation()
  11. Check if vehicle is upright: local up = obj:getDirectionVectorUp(); if up.z > 0.8 then ... end
  12. Deflate a specific tire: beamstate.deflateTire(wheelId)
  13. Get total vehicle mass: local mass = 0; for _, n in pairs(v.data.nodes) do mass = mass + n.nodeWeight end
  14. Apply a global torque impulse: obj:applyTorqueAxisCouple(500, node1, node2, node3)
  15. Check for node collision: Hook into onNodeCollision(p).

3. Input & Control (#electronics #input)

  1. Override user steering: electrics.values.steeringOverride = 0.5
  2. Disable user throttle: electrics.values.throttleOverride = 0
  3. Read raw user steering: local rawSteer = electrics.values.steering_input
  4. Detect controller button event: Use input.event("name", val, filter)
  5. Create a non-blocking timer: local t = HighPerfTimer(); ... if t:stop() > 1000 then ... end
  6. Throttled update (2Hz): timer = timer + dt; if timer > 0.5 then timer = 0; ... end
  7. Toggle hazard lights: electrics.toggle_warn_signal()
  8. Set ignition to 'On': electrics.setIgnitionLevel(2)
  9. Check if parking brake is on: if (electrics.values.parkingbrake or 0) > 0 then ... end
  10. Smooth a value over time: val = smoother:get(target, dt)

4. UI & Communication (#ui #communication)

  1. Trigger screen message: guihooks.message("Impact!", 5, "safety")
  2. Send data to UI app: guihooks.queueStream("myKey", myValue)
  3. Call function in Game Engine: obj:queueGameEngineLua("print('Hello')")
  4. Send command to another vehicle: obj:queueObjectLuaCommand(targetId, "electrics.values.horn = 1")
  5. Play a one-time sound effect: obj:playSFXOnce("event:>Vehicle>Failures>tire_burst", nodeId, 1, 1)
  6. Register damage update callback: damageTracker.registerDamageUpdateCallback(myFunc)
  7. Check if first player is seated: if playerInfo.firstPlayerSeated then ... end
  8. Draw debug line in world: obj.debugDrawProxy:drawLine(pos1, pos2, color)
  9. Draw debug text at node: obj.debugDrawProxy:drawNodeText(nodeId, color, "Broken!")
  10. Sync variable to peer vehicle: obj:queueObjectLuaCommand(id, "myModule.syncValue(" .. myVal .. ")")

5. Niche Modding Tasks

  1. Get vehicle's unique object ID: local id = obj:getId()
  2. Check if in walking/unicycle mode: local isWalking = (controller.mainController.typeName == "playerController")
  3. Disable a powertrain device: powertrain.getDevice("rearDiff"):disable()
  4. Check if a node is underwater: if obj:inWater(nodeId) then ... end
  5. Get environmental air density: local density = obj:getRelativeAirDensity()
  6. Check if any player is in vehicle: if playerInfo.anyPlayerSeated then ... end
  7. Change node friction at runtime: obj:setNodeFrictionSlidingCoefs(id, 1.0, 0.8)
  8. Get gravity magnitude: local g = powertrain.currentGravity
  9. Trigger custom UI event: guihooks.trigger("MyEvent", {val = 1})
  10. Lock a differential: powertrain.setDeviceMode("rearDiff", "locked")

Vehicle Lua Cheat Sheet

60+ copy-paste one-liners for vehicle scripting — physics, electrics, powertrain, damage, UI, and inter-VM communication.

Vehicle Modding Guide

How to add custom logic to vehicles safely — extensions vs controllers, the electrics data bus, powertrain API, safe overrides, and UI visibility.

On this page

1. Powertrain & Torque (#powertrain #torque #rpm)2. JBeam & Physics (#physics #jbeam #pos #force)3. Input & Control (#electronics #input)4. UI & Communication (#ui #communication)5. Niche Modding Tasks