Extensions Module Reference
Infrastructure for managing vehicle extensions, dependency resolution, and event hooking. This module allows for modular scripts to be loaded, unloaded, and updated at runtime, providing a flexible pl
Infrastructure for managing vehicle extensions, dependency resolution, and event hooking. This module allows for modular scripts to be loaded, unloaded, and updated at runtime, providing a flexible plugin architecture.
See Also
- Extensions Folder: Detailed list of common extensions.
- InitSequence: For extension loading order.
Public API - Loading & Lifecycle
| Function | Signature | Description |
|---|---|---|
extensions.load | (...) | Loads and initializes named extensions. Automatically processes dependencies and triggers onExtensionLoaded. |
extensions.unload | (name) | Disables and unloads an extension and any modules that depend exclusively on it. |
extensions.reload | (path) | Hot-reloads an extension from disk, clearing the Lua cache and re-initializing the module. |
extensions.refresh | (name) | Refreshes the internal registration of a module without reloading the file from disk. |
extensions.loadModulesInDirectory | (dir, exclude) | Automatically scans and loads all .lua files found in the specified directory. |
Usage Example
extensions.load("cruiseControl", "telemetryLogger")Public API - Hooking & Dispatch
| Function | Signature | Description |
|---|---|---|
extensions.hook | (funcName, ...) | Dispatches an event to every active extension that implements the specified function. This is the primary way extensions communicate with the core engine. |
extensions.hookNotify | (funcName, ...) | Similar to hook, but also triggers any one-time callbacks registered via setCompletedCallback. |
extensions.hookExcept | (exceptions, funcName, ...) | Dispatches a hook to all extensions except those listed in the exceptions table. |
Usage Example
extensions.hook("updateGFX", dt)Public API - State & Persistence
| Function | Signature | Description |
|---|---|---|
extensions.deserialize | (data, filter) / getSerializationData(reason) | Standard interface for saving and restoring the internal state of all extensions (used for CTRL+L reloads). |
extensions.disableSerialization | (...) | Excludes specific modules from the automatic state saving process. |
Public API - Utility & Debug
| Function | Signature | Description |
|---|---|---|
extensions.isExtensionLoaded | (name) | Returns true if the named extension is currently active. |
extensions.getLoadedExtensionsNames | (excludeVirtual) | Returns a sorted list of all active extension names. |
extensions.addModulePath | (dir) | Adds a directory to the Lua require search path. |
extensions.printExtensions | () / printHooks(funcName) | Debug utilities that log the current extension topology and implemented hooks to the console. |
EnergyStorage Module Reference
Module defined in `lua/vehicle/energyStorage.lua`. Central manager for all vehicle energy containers (fuel tanks, batteries, N2O tanks, pressure tanks). Handles discovery from JBeam, links containers to powertrain devices that consume energy, tracks fuel levels and leak states, and manages rupture callbacks when beams break.
Fire Module Reference
Module defined in `lua/vehicle/fire.lua`. Physics-based fire and thermal simulation. Fire can be triggered by high temperatures, collisions, or fuel tank ruptures.