RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

BeamObjectPool Folder OverviewObjectPool main 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

API Referenceobjectpool

ObjectPool main Reference

Module defined in `lua/objectpool/main.lua`. Object pool Lua VM that manages vehicle objects in a shared pool, providing spawn, get, move, set, and delete operations. Acts as the bridge between the Be

Module defined in lua/objectpool/main.lua. Object pool Lua VM that manages vehicle objects in a shared pool, providing spawn, get, move, set, and delete operations. Acts as the bridge between the BeamNG engine and individual vehicle Lua VMs.


Functions/Exports

Pool Operations (global)

getObject(objId)

Returns lpack-encoded object data for the given object ID.

moveObject(objId)

Removes object from pool and returns its lpack-encoded data (transfer ownership).

setObject(objId, objDataStr)

Stores lpack-decoded object data into the pool at the given ID.

deleteObject(objId)

Removes object from pool (sets to nil).

initPool()

No-op initialization function for the thread Lua VM.

Vehicle Lifecycle (global)

init(path, initData)

Called in the object Lua VM to initialize a vehicle:

  • Decodes lpack initData string
  • Loads vehicle via jbeam/stage2.loadVehicleStage2()
  • Stores loaded object in pool keyed by obj:getId()
  • Returns true on success, false on failure (triggers Lua VM unload)

Event Handlers (global)

onNodeCollision(id1, pos, normal, nodeVel, perpendicularVel, slipVec, slipVel, slipForce, normalForce, depth, materialId1, materialId2)

Node collision callback (currently no-op with commented dump).

onVehicleReset(retainDebug)

Vehicle reset callback (empty).

onBeamBroke(id, energy)

Beam break callback (empty).

onBeamDeformed(id, ratio)

Beam deformation callback (empty).

Internal Management (global)

_setObj(objId, _obj)

Sets the current object context - sets obj, objectId, and objData globals via rawset.

__newIndexHandler(t, key, val)

Metatable __newindex handler - writes to current object's data table.

__indexHandler(t, key)

Metatable __index handler - reads from current object's data table.

Environment Setup

  • vmType = 'objectpool'
  • Package path includes: ge, gui, vehicle, common, libs, luasocket, core/scripts
  • Requires: luaCore, utils, devUtils, ve_utils, mathlib
  • Aliases: float3 = vec3
  • Overrides print to use log("A", "print", ...)

Usage

This module is loaded by BeamNG as the objectpool Lua VM. Not called directly by user scripts.

Internal Notes

  • Uses _G metatable to redirect global reads/writes to the current object's data table
  • _setObj must be called before any per-object operations to set context
  • lpack used for serialization between pool and vehicle VMs
  • moveObject removes from pool (ownership transfer), while getObject is read-only
  • Vehicle init uses jbeam stage2 loader - expects initData.vdata in the decoded table
  • Empty event handlers serve as extension points for future collision/damage logic

BeamObjectPool Folder Overview

Single-file module implementing BeamNG's object pool Lua VM.

UI Apps - HUD Widgets

UI Apps are in-game HUD widgets like the tachometer, compass, minimap, and lap times. They run as Vue components overlaid on the game view.

On this page

Functions/ExportsPool Operations (global)getObject(objId)moveObject(objId)setObject(objId, objDataStr)deleteObject(objId)initPool()Vehicle Lifecycle (global)init(path, initData)Event Handlers (global)onNodeCollision(id1, pos, normal, nodeVel, perpendicularVel, slipVec, slipVel, slipForce, normalForce, depth, materialId1, materialId2)onVehicleReset(retainDebug)onBeamBroke(id, energy)onBeamDeformed(id, ratio)Internal Management (global)_setObj(objId, _obj)__newIndexHandler(t, key, val)__indexHandler(t, key)Environment SetupUsageInternal Notes