filterchain Reference
Module defined in `lua/common/utils/filterchain.lua`. Functional programming filter chain for signal processing - chains composable filter objects (smooth, interval, scale, digitize, etc.) into a proc
Module defined in lua/common/utils/filterchain.lua. Functional programming filter chain for signal processing - chains composable filter objects (smooth, interval, scale, digitize, etc.) into a processing pipeline.
Exports
Functions
M.test()
Run built-in test/demo of the filter chain system.
Filter Types (via internal F table)
F.smooth(rate)
Smooth a value toward a target at a given rate per second.
F.interval(offsetTime, timeOn, timeOff)
Generate on/off intervals (blinking/pulsing).
F.scale(scaleVal)
Multiply value by a constant.
F.digitize(threshold)
Convert to 0/1 based on threshold (default 0.5).
F.floor()
Apply math.floor to value.
F.clamp(minval, maxval)
Clamp value between min and max (default 0–1).
F.examine(str, commonArgumentsCount)
Debug filter - logs all values passing through with a label.
- Parameters:
str- string - Debug labelcommonArgumentsCount- number|nil - Number of common args to skip (default 0)
F.startdelay(startdelay)
Delay filter activation until the input has been high for a duration.
- Parameters:
startdelay- number - Required high-time in seconds before passing through
Factory Function (internal)
newFilterchain(filterlist, debug, commonFilterArguments, codeArgs)
Create a new filter chain from a list of filter specifications.
- Parameters:
filterlist- table - Array of filter definitionsdebug- boolean - Enable debug outputcommonFilterArguments- table - Shared arguments (e.g.,{'dt'})codeArgs- table - Additional code-level arguments
Internal Notes
- Proof-of-concept functional programming pattern by BeamNG
F.plusandF.pushConstantexist in source but are commented out (experimental)- Filters are objects with a
:get(dt, value)method getGeneratorcreates filter instances from specification tablesgetVarByNameInScoperesolves dotted variable names in nested tables- Common filter argument is
dt(delta time) passed to all filters
debugDraw Reference
Module defined in `lua/common/utils/debugDraw.lua`. Lightweight debug drawing API using packed integer colors instead of ColorF/ColorI. Wraps FFI calls to the C++ `BNG_DBG_DRAW_*` functions.
utils/ - Utility Modules
General-purpose utility modules for debugging, profiling, networking, graphics, and data processing.