API Referenceve
Material Module Reference
Module defined in `lua/vehicle/material.lua`. Manages dynamic vehicle materials, "glowmaps" (lighting), and "deformmaps" (damage textures).
Module defined in lua/vehicle/material.lua. Manages dynamic vehicle materials, "glowmaps" (lighting), and "deformmaps" (damage textures).
Internal Interactions
This module heavily utilizes the obj C++ binding to apply material changes to the physical vehicle model:
obj:switchMaterial(msc, mat): Swaps the current material.obj:resetMaterials(msc): Resets a material switch.obj:setMaterialEmissiveFactor(msc, color): Scales the emissivity (glow) of a material switch.
Key Concepts
- Glowmaps: Link JBeam triggers (like
brake,highbeam) to specific material states. When the trigger value is high, the material switches to its "on" version (emissive). - Deformmaps: Used for visual damage. When a beam associated with a material is deformed, the material can switch to a cracked or damaged version.
Public API
| Function | Signature | Description |
|---|---|---|
forceReset | () | Reverts materials and clears break tracking. |
init | () | Compiles evaluation functions for triggers. Returns M. |
reset | () | Returns materials to "off" state. |
switchBrokenMaterial | (beam) | Switches meshes to "damaged" textures and plays sounds. |
updateGFX | () | Re-evaluates materials (like light glows) based on values in electrics.values. |
Usage Example
material.forceReset()material.init()Mapmgr Module Reference
Module defined in `lua/vehicle/mapmgr.lua`. This module interfaces the vehicle with the global navigation graph (NavGraph), handles tracking of nearby vehicles, and provides world analysis tools like
BeamNG Math & Unit Conversions Reference
A centralized reference for common unit conversions and math constants used in BeamNG vehicle Lua.