RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

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

BeamNG Game Engine Lua Cheat Sheet

A collection of 50+ high-frequency one-liners and snippets for game engine-side scripting.

A collection of 50+ high-frequency one-liners and snippets for game engine-side scripting.


1. Vehicle Spawning & Management (#core #vehicle #spawn)

TaskOne-Liner
Spawn Vehiclelocal veh = spawn.spawnVehicle("etk800", "vehicles/etk800/default.pc", vec3(0,0,100), quat(0,0,0,1))
Delete Vehicleveh:delete()
Get Player Vehicle (0)local veh = be:getPlayerVehicle(0)
Get Vehicle by IDlocal veh = be:getObjectByID(vehID) or getObjectByID(vehID)
Get Vehicle by Namelocal veh = scenetree.findObject("vehiclename")
Get Vehicle Countlocal count = be:getObjectCount()
Iterate All Vehiclesfor i = 0, be:getObjectCount() - 1 do local veh = be:getObject(i) end
Get Vehicle IDlocal id = veh:getID()
Get Vehicle JBeam Filelocal jbeam = veh:getJBeamFilename()
Reset Vehicleveh:reset()
Set Vehicle Activeveh:setActive(true)
Set Vehicle Visibleveh:setHidden(false)

2. Teleport & Transform (#core #physics #pos #teleport)

TaskOne-Liner
Get Positionlocal pos = veh:getPosition()
Get Rotationlocal rot = veh:getRotation()
Get Velocitylocal vel = veh:getVelocity()
Teleport Vehicleveh:setPosition(Point3F(x, y, z))
Teleport with Rotationveh:setPositionRotation(x, y, z, rx, ry, rz, rw)
Set Rotationveh:setRotation(QuatF(0, 0, 0, 1))
Set Transform Matrixveh:setTransform(MatrixF(quat, pos))
Move Vehicle Relativelocal pos = veh:getPosition(); veh:setPosition(Point3F(pos.x + 10, pos.y, pos.z))
Teleport to Groundveh:setPosition(Point3F(x, y, z)); veh:reset()
Get Direction Vectorlocal dir = veh:getDirectionVector()
Set Velocityveh:setVelocity(vec3(0, 0, 0))

3. Environment & Weather (#core #environment #time #weather)

TaskOne-Liner
Set Time of Daycore_environment.setTimeOfDay({time = 0.5}) -- 0.0-1.0 float (0.5 = noon)
Set Gravitycore_environment.setGravity(-9.81) -- number, not vec3
Pause SimulationsimTimeAuthority.pause(true)
Resume SimulationsimTimeAuthority.pause(false)
Set Physics Speedbe:setPhysicsSpeedFactor(0.5) -- half speed
Start Physicsbe:physicsStartSimulation()
Stop Physicsbe:physicsStopSimulation()
Get Ground Heightlocal height = be:getSurfaceHeightBelow(pos)

4. Missions & Gameplay (#gameplay #mission #core)

TaskOne-Liner
Start Missiongameplay_missions_missionManager.start(missionId)
Stop Missiongameplay_missions_missionManager.stop(missionId)
Get Active Missionlocal id = gameplay_missions_missionManager.getForegroundMissionId()
Get Mission by IDlocal m = gameplay_missions_missions.getMissionById(missionId)
Check Mission Unlockedlocal ok = gameplay_missions_unlocks.getSimpleUnlockedStatus(missionId)
Aggregate Attemptgameplay_missions_progress.aggregateAttempt(missionId, attempt, "default")

5. Career System (#career #economy)

TaskOne-Liner
Get Moneylocal money = career_modules_playerAttributes.getAttributeValue("money")
Add Attributescareer_modules_playerAttributes.addAttributes({money = 1000}, {label = "reward"})
Pay Moneycareer_modules_payment.pay({money = {amount = 500, canBeNegative = false}}, {label = "purchase"})
Can Affordlocal ok = career_modules_payment.canPay({money = {amount = 500, canBeNegative = false}})
Check Career Activeif career_career and career_career.isActive() then ... end
Get Inventorylocal vehicles = career_modules_inventory.getVehicles()
Get Current Vehiclelocal id = career_modules_inventory.getCurrentVehicle()

6. UI & Notifications (#ui #core)

TaskOne-Liner
Show Toastguihooks.trigger('toastrMsg', {type = 'info', title = 'Hello', msg = 'World'})
Show Messageguihooks.message("Hello World!", 5, "info")
Open UI Moduleguihooks.trigger('MenuOpenModule', 'vehicleselect')
Hide Menuguihooks.trigger('MenuHide')
Change Game Stateguihooks.trigger('ChangeState', {state = 'menu'})
Stream Data to UIguihooks.queueStream('key', value)
Flush Streamsguihooks.sendStreams()

7. Map & Navigation (#core #map)

TaskOne-Liner
Get Current Maplocal mapData = map.getMap()
Get Road Nodeslocal nodes = map.getMap().nodes
Get Node Positionlocal pos = nodes["nodename"].pos
Get Node Linkslocal links = nodes["nodename"].links
Force Map Loadmap.assureLoad()
Get Ground Heightlocal height = be:getSurfaceHeightBelow(pos)

8. Scene Tree (#core #scene)

TaskOne-Liner
Find Object by Namelocal obj = scenetree.findObject("objectName")
Find Objects by Classlocal ids = scenetree.findClassObjects("TSStatic")
Find Object by IDlocal obj = scenetree.findObjectById(id)
Hide Objectobj:setHidden(true)
Show Objectobj:setHidden(false)
Get Class Namelocal class = obj:getClassName()
Check if Hiddenlocal hidden = obj:isHidden()
Get Object Positionlocal pos = obj:getPosition()
Set Object Positionobj:setPosition(Point3F(x, y, z))
Delete Objectobj:delete()

9. Extensions (#core #extension)

TaskOne-Liner
Load Extensionextensions.load('myExtension')
Unload Extensionextensions.unload('myExtension')
Reload Extensionextensions.reload('myExtension')
Check Loadedlocal loaded = extensions.isExtensionLoaded('myExtension')
Trigger Hookextensions.hook('onResetGameplay', playerID)
Get Loaded Nameslocal names = extensions.getLoadedExtensionsNames()

10. GE ↔ VE Communication (#communication #core)

TaskOne-Liner
Send Command to Vehicleveh:queueLuaCommand("extensions.load('controller')")
Send to Vehicle by IDbe:getObjectByID(id):queueLuaCommand("electrics.set_motor_boost(1)")
Print from VEobj:queueGameEngineLua("print('Hello from VE')")
Call VE Functionveh:queueLuaCommand("myFunction()")

11. Utility Functions (#core #utility)

TaskOne-Liner
JSON Encodelocal str = jsonEncode({key = "value"})
JSON Decodelocal data = jsonDecode('{"key": "value"}')
Pretty JSONlocal pretty = jsonEncodePretty({a = 1, b = 2})
Read JSON Filelocal data = jsonReadFile("path/to/file.json")
Write JSON FilejsonWriteFile("path/to/file.json", data, true)
Dump Tableprint(dumps(myTable))
Deep Copylocal copy = deepcopy(original)
Clamp Valuelocal val = clamp(x, 0, 100)
Lerplocal val = lerp(a, b, 0.5)
Signlocal s = sign(x) -- -1, 0, or 1
Roundlocal r = round(3.14159) -- rounds to nearest int

12. Game State (#core #state)

TaskOne-Liner
Set Game Statecore_gamestate.setGameState('freeroam', 'freeroam', 'freeroam')
Request Statecore_gamestate.requestGameState()
Start Freeroamfreeroam_freeroam.startFreeroam(levelPath)
Return to MenureturnToMainMenu()

13. Camera (#core #camera)

TaskOne-Liner
Set Camera by Namecore_camera.setByName(0, "orbit") -- playerIndex, modeName
Set Camera FOVcore_camera.setFOV(0, 60)
Set Camera Positioncore_camera.setPosition(0, pos)
Set Camera Distancecore_camera.setDistance(0, 10)
Set Camera Rotationcore_camera.setRotation(0, rot)

Quick Reference Count

CategoryCount
Vehicle Spawning & Management11
Teleport & Transform11
Environment & Physics8
Missions & Gameplay6
Career System7
UI & Notifications7
Map & Navigation6
Scene Tree10
Extensions6
GE ↔ VE Communication4
Utility Functions11
Game State4
Camera5
Total96+

See Also

  • Globals - Complete global objects reference
  • Property Tree - Object path lookup
  • TL;DR Architect - Extension lifecycle and hooks

BeamNG ImGui Style Guide

Visual patterns and conventions extracted from the Freeroam Event Editor. Use these patterns for consistent, polished editor UIs.

GE Developer Recipes

A comprehensive collection of 50+ practical solutions for common Game Engine (GE) development tasks. Each recipe is copy-paste ready with explanations.

On this page

1. Vehicle Spawning & Management (#core #vehicle #spawn)2. Teleport & Transform (#core #physics #pos #teleport)3. Environment & Weather (#core #environment #time #weather)4. Missions & Gameplay (#gameplay #mission #core)5. Career System (#career #economy)6. UI & Notifications (#ui #core)7. Map & Navigation (#core #map)8. Scene Tree (#core #scene)9. Extensions (#core #extension)10. GE ↔ VE Communication (#communication #core)11. Utility Functions (#core #utility)12. Game State (#core #state)13. Camera (#core #camera)Quick Reference CountSee Also