SlotSystem Reference
Module defined in `lua/common/jbeam/slotSystem.lua`. Resolves the vehicle part tree from configuration, handling slot matching, part selection, and part unification (merging).
Module defined in lua/common/jbeam/slotSystem.lua. Resolves the vehicle part tree from configuration, handling slot matching, part selection, and part unification (merging).
Exports
Functions
M.partFitsSlot(part, slot)
Checks if a part is compatible with a slot definition, supporting both slots v1 (type) and v2 (allowTypes/denyTypes).
- Parameters:
part- table - Part data withslotType(string or table of strings)slot- table - Slot definition withtype(v1) orallowTypes/denyTypes(v2)
- Returns:
boolean, string- false and error message on failure
M.findParts(ioCtx, vehicleConfig)
Recursively resolves the entire part tree from vehicle configuration. Starting from the main part, walks all slots, selects parts (from user config or defaults), and builds both a hierarchical tree and flat maps.
- Parameters:
ioCtx- table - IO context fromjbeamIO.startLoadingvehicleConfig- table - Vehicle configuration withmainPartNameand eitherparts(flat map) orpartsTree(hierarchical dict)
- Returns: table, table, table, table, table, table, table -
rootPart, unifyJournal, unifyJournalC, chosenPartsTree, slotPartMap, activePartsData, activePartsrootPart- table - The main part dataunifyJournal- table - Array of merge operations (post-order)unifyJournalC- table - Array of merge operations (pre-order, for components)chosenPartsTree- table - Hierarchical tree of chosen parts with slot metadataslotPartMap- table -{slotPath → partName}activePartsData- table -{partName → deepcopy of part data}activeParts- table -{partPath → partName}
M.unifyPartJournal(ioCtx, unifyJournal)
Replays the unify journal to merge all chosen parts into the root part. Each journal entry triggers unifyParts which merges sections from child parts into the parent.
- Parameters:
ioCtx- table - IO contextunifyJournal- table - Journal fromfindParts
- Returns: boolean -
trueon success
Internal Notes
partFitsSlotv1 quirk: For slots v1, whenpart.slotTypeis a table, the check usesnot tableContains- meaning it returnstruewhen the slot type is NOT in the table. This appears to be a bug in the game code but is the actual runtime behavior.- Part selection priority: (1) user-specified part from config, (2) slot default, (3) empty.
unifyPartshandles three merge cases per section:- New section: direct assignment with slot options injected
- Existing table section: appends rows with slot options, handles
$+/$*/$</$>merge modifiers for numeric values - Basic data: overwrites (except
slotTypeandpartName)
chosenPartsTreeentries have:id,path,chosenPartName,partPath,children,suitablePartNames,unsuitablePartNames,decisionMethoddecisionMethodvalues:"user","user-empty","default","default-empty"- Recursion limit: 50 levels deep.
- Uses an ordered table implementation (
newT) for deterministic iteration.
SectionMerger Reference
Module defined in `lua/common/jbeam/sectionMerger.lua`. Merges duplicate/aliased JBeam sections together for backward compatibility (e.g. `triggers2` → `triggers`).
TableSchema Reference
Module defined in `lua/common/jbeam/tableSchema.lua`. Converts JBeam table-format data (header row + data rows) into keyed object dictionaries, applying options and special value replacements.