RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Debug DrawingGPU Mesh StructsImGui FFIMath Structs (FFI)FFI C DefinitionsPID ControllersCSV LibraryDelay LineDequeDevelopment UtilitiesEvent ReferenceExtension SystemSignal FiltersGraph PathfindingUI BridgeInput Filter Constants2D Bilinear InterpolationIntrospectionJBeam Pretty PrinterJSON AST ParserSJSON ParserJSON Debug ParserJSON Pretty PrinterK-D Tree (2D Boxes)K-D Tree (3D)K-D Tree (3D)Lua SerializerC++/Lua BindingLua CoreLua ProfilerMath LibraryParticlesQuadtreeSettingsTCP ServerTimer SchedulerUtility Library

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 Referencecommon

Development Utilities

Module defined in `lua/common/devUtils.lua`. Development utilities for sandboxed Lua execution, module local variable introspection, global state snapshots, and table recursion detection.

Module defined in lua/common/devUtils.lua. Development utilities for sandboxed Lua execution, module local variable introspection, global state snapshots, and table recursion detection.


Exports

All exports are global functions (no module table).

Functions

executeLuaSandboxed(cmd, source)

Executes a Lua string in a sandboxed environment with stdout capture.

  • Parameters:
    • cmd - string - Lua code to execute
    • source - string|nil - Source name for error reporting (default: "executeLuaSandboxed")
  • Returns: any, table|nil - Result of execution (or error string), and captured stdout lines

getModuleLocals(moduleTbl)

Returns all upvalue locals used by functions in a module table. Useful for introspection and serialization.

  • Parameters:
    • moduleTbl - table - The module table to inspect
  • Returns: table - Map of local variable names to their values

createGlobalSnapshot(filename)

Serializes the entire global Lua state to a JSON file for debugging. Captures all global tables, their locals, extension state, and variables.

  • Parameters:
    • filename - string - Output JSON filename

tableFindRecursion(tbl)

Detects tables that appear at multiple paths within a table hierarchy (shared references).

  • Parameters:
    • tbl - table - Root table to inspect
  • Returns: number, table - Count of duplicate table references, and a map of table pointers to their paths

Internal Notes

  • executeLuaSandboxed is NOT truly safe - it can access hidden objects through the environment
  • The sandbox captures print() output and redirects it to a table
  • createGlobalSnapshot skips functions, extension modules, and the global table itself
  • Internal helpers: _findUpValuesFromFunction, _recFindUpvalues, _cleanupCloneTbl, _createGraphviz

See Also

  • cdefDebugDraw Reference - Related reference
  • cdefGpuMesh Reference - Related reference
  • cdefImgui Reference - Related reference
  • Common Libraries Overview - Guide

Deque

Module defined in `lua/common/dequeue.lua`. Double-ended queue (deque) implementation supporting push/pop from both ends, rotation, removal, and iteration. Based on Pierre Chapuis's library.

Event Reference

Module defined in `lua/common/event.lua`. Implements a simple event/delegate class for publish-subscribe patterns. Subscribers register functions that get called when the event fires.

On this page

ExportsFunctionsexecuteLuaSandboxed(cmd, source)getModuleLocals(moduleTbl)createGlobalSnapshot(filename)tableFindRecursion(tbl)Internal NotesSee Also