RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

cdefDebugDraw ReferencecdefGpuMesh ReferencecdefImgui ReferencecdefMath Referencecdefs ReferencecontrolSystems Referencecsvlib ReferencedelayLine Referencedequeue ReferencedevUtils ReferenceEvent Referenceextensions Referencefilters Referencegraphpath Referenceguihooks ReferenceinputFilters ReferenceinterpolatedMap Referenceintrospection ReferencejbeamWriter Referencejson-ast Referencejson ReferencejsonDebug ReferencejsonPrettyEncoderCustom Referencekdtreebox2d Referencekdtreebox3d Referencekdtreepoint3d Referencelpack ReferenceluaBinding ReferenceluaCore ReferenceluaProfiler Referencemathlib Referenceparticles Referencequadtree Referencesettings ReferencetcpServer ReferencetimeEvents Referenceutils 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 Referencecommon

jbeamWriter Reference

Module defined in `lua/common/jbeamWriter.lua`. A specialized JSON pretty-printer for jbeam files that formats objects with indentation up to a configurable depth, then falls back to compact encoding

Module defined in lua/common/jbeamWriter.lua. A specialized JSON pretty-printer for jbeam files that formats objects with indentation up to a configurable depth, then falls back to compact encoding for deeper levels.


Exports

Functions

M.writeFile(filename, obj)

Writes a Lua table to a file as pretty-printed jbeam JSON with depth-limited formatting (max level 2).

  • Parameters:
    • filename - string - Output file path
    • obj - table - Data to serialize
  • Returns: boolean - True on success, false on failure

Internal Notes

  • Uses jsonEncodePrettyJbeam(v, lvl, numberPrecision, maxLevel) internally
  • When lvl > maxLevel, falls back to compact jsonEncode(v) for deeper structures
  • The components section at level 1 always gets full pretty-printing (maxLevel = 999)
  • Handles special cases: inf → 9e999, vec3 and quat cdata types → JSON objects
  • String escaping handles backslashes, newlines, tabs, quotes, carriage returns
  • Numbers use %.10g format by default, or fixed-precision when numberPrecision is specified

introspection Reference

Module defined in `lua/common/introspection.lua`. Gathers method information from all globally registered classes and built-in modules for runtime reflection.

json-ast Reference

Module defined in `lua/common/json-ast.lua`. A JSON/jbeam AST (Abstract Syntax Tree) parser that preserves formatting, comments, and whitespace. Used by the in-game jbeam editor for lossless round-tri

On this page

ExportsFunctionsM.writeFile(filename, obj)Internal Notes