particles Reference
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 arrayi- 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 arrays- 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 arrays- 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 -
materialsarray andmaterialsMaplookup table
Internal Notes
- Materials and particle definitions are loaded from
lua/common/particles.jsonat require time - The
materialsMapkey ismaterialID1 * 10000 + materialID2with 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,dynamicflag
mathlib Reference
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 Reference
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