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

Particles

Module defined in `lua/common/particles.lua`. Manages particle material data and lookup tables for collision-based particle effects (e.g., tire smoke, sparks, debris).

Module defined in lua/common/particles.lua. Manages particle material data and lookup tables for collision-based particle effects (e.g., tire smoke, sparks, debris).


Exports

Functions

M.getMaterialByID(mats, i)

Retrieves a material definition by its index.

  • Parameters:
    • mats - table - Materials array
    • i - number|nil - Material index
  • Returns: table - Material data for the given ID

M.getMaterialIDByName(mats, s)

Finds a material index by name; returns a safe fallback if not found.

  • Parameters:
    • mats - table - Materials array
    • s - string - Material name
  • Returns: number - Material index (falls back to min(3, #mats) if not found)

M.getOrAddMaterialIDByName(mats, s)

Finds a material index by name, creating a temporary definition if not found.

  • Parameters:
    • mats - table - Materials array
    • s - string - Material name
  • Returns: number - Material index (newly created if not found)

M.getMaterialsParticlesTable()

Returns the full materials and material-pair-to-particles mapping tables.

  • Returns: table, table - materials array and materialsMap lookup table

Internal Notes

  • Materials and particle definitions are loaded from lua/common/particles.json at require time
  • The materialsMap key is materialID1 * 10000 + materialID2 with IDs sorted so the larger is first
  • Each particle definition has dynamically compiled comparison functions from expressions like "X > 5" where X is replaced with the actual field value
  • Comparison fields: perpendicularVel, slipVel - expressions evaluate against runtime collision data
  • Material definitions include: name, colorR, colorG, colorB, dynamic flag

See Also

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

Math Library

Module defined in `lua/common/mathlib.lua`. Core math library providing `vec3` and `quat` types with operator overloading, plus extensive geometry utilities (ray intersections, OBB tests, splines, etc

Quadtree

Module defined in `lua/common/quadtree.lua`. Quadtree spatial data structure for 2D bounding boxes with insert, remove, query, and compression. Query is remove-safe (removing items during iteration do

On this page

ExportsFunctionsM.getMaterialByID(mats, i)M.getMaterialIDByName(mats, s)M.getOrAddMaterialIDByName(mats, s)M.getMaterialsParticlesTable()Internal NotesSee Also