Backwards Compatibility Module Reference
Module defined in `lua/vehicle/backwardsCompatibility.lua`. This system acts as a translation layer for older vehicle JBeam configurations, converting legacy definitions (pre-powertrain/controller era
Module defined in lua/vehicle/backwardsCompatibility.lua. This system acts as a translation layer for older vehicle JBeam configurations, converting legacy definitions (pre-powertrain/controller era) into modern modular components at runtime.
See Also
- Powertrain: The modern drive simulation system.
- Controller: Modern modular logic hub.
- Drivetrain: The legacy physical drivetrain system.
Public API
| Function | Signature | Description |
|---|---|---|
backwardsCompatibility.init | () | The main entry point called during vehicle initialization. It runs a series of heuristic checks to upgrade legacy JBeam data structures. Sub-processes: 1. checkOldESC(): If escConfig is found in JBeam, it automatically injects an esc controller and maps the old configuration to it. 2. checkOldDrivetrain(): If powertrain is missing but legacy engine or differentials are present, it triggers the full compatibility conversion. 3. checkTrailerIgnitionStates(): Analyzes the vehicle for torque sources. If none are found (like a trailer), it restricts the vehicle to ignition level 0 (Off) to prevent ghost engine effects. |
Compatibility Systems
Legacy Drivetrain Migration
When a vehicle uses the old drivetrain system, this module dynamically generates a modern powertrain tree:
1. Engine Conversion (createCompatibilityEngine)
- Legacy Source:
engineandenginetorqueJBeam sections. - Result: Creates a
combustionEnginedevice named"mainEngine"and a matchinggearboxdevice. - Properties Migrated: RPM limits, inertia, friction, thermals (radiator, oil, etc.), and torque curves.
- Clutch Handling: Automatically adds a
frictionClutchfor manuals or aviscousClutchfor older automatics.
2. Differential Conversion (createCompatibilityDifferentials)
- Legacy Source:
differentialsJBeam section. - Result: Generates a tree of
differentialandshaftdevices. - Logic:
- Handles single-diff (FWD/RWD) and dual-diff (AWD) setups.
- Automatically adds necessary
driveshaftandaxlecomponents to complete the graph. - Converts legacy
lsd,open, andlockedstates to modern differential modes.
3. Controller Injection (createCompatibilityController)
- Result: Injects a
vehicleControllerif an engine is present. - Logic: Automatically calculates shift points and clutch launch parameters based on the legacy engine's idle and max RPM.
AI Module Reference
Module defined in `lua/vehicle/ai.lua`. This module handles high-level artificial intelligence behaviors, including pathfinding, traffic simulation, and reactive driving modes (chase, flee, follow).
Bdebug Module Reference
Module defined in `lua/vehicle/bdebug.lua`. Lightweight proxy that delegates all debug visualization calls to the heavyweight `bdebugImpl` module. Use this module to toggle node/beam visualization, skeleton overlays, center-of-gravity markers, and collision triangle rendering without loading the full debugger until needed.