API ReferenceGE Extensionscorevehicle
Vehicle Part Management
Manages vehicle part configurations - saving/loading `.pc` files, highlighting/selecting parts in the UI, and merging config changes (parts, vars, paints) into the active vehicle.
Manages vehicle part configurations - saving/loading .pc files, highlighting/selecting parts in the UI, and merging config changes (parts, vars, paints) into the active vehicle.
Public API
| Function | Signature | Description |
|---|---|---|
M.save | (filename) | Saves current player vehicle part config to a .pc file |
M.saveLocal | (fn) | Saves config relative to the vehicle directory |
M.savedefault | () | Sets the current vehicle as the default (settings/default.pc) |
M.saveLocalScreenshot | (fn) | Begins screenshot workflow for config thumbnail |
M.saveLocalScreenshot_stage2 | (fn) | Stage 2 of screenshot capture |
M.saveVehicleCollection | (collectionTree, filename) | Saves a multi-vehicle collection (format 4) |
M.compileVehicleCollection | (collectionTree) | Compiles collection tree into a flat vehicles list |
M.buildConfigFromString | (vehicleDir, configData, onlyReturnChosenConfig) | Parses a config from string/table/file path |
M.setConfig | (inData, respawn) | Merges config data into the player vehicle (alias for mergeConfig) |
M.setConfigPaints | (data, respawn) | Merges paint data into config |
M.setConfigVars | (data, respawn) | Merges tuning variables into config |
M.setPartsConfig | (data, respawn) | Deprecated - use setPartsTreeConfig |
M.setPartsTreeConfig | (dataTree, respawn) | Merges a parts tree into the config |
M.getConfig | () | Returns the current player vehicle config table |
M.resetConfig | () | Resets parts and vars to empty |
M.resetAllToLoadedConfig | () | Reloads the original .pc file |
M.resetPartsToLoadedConfig | () | Resets parts only to loaded config |
M.resetVarsToLoadedConfig | () | Resets vars only to loaded config |
M.loadLocal | (filename, respawn) | Loads a config file and replaces the vehicle |
M.removeLocal | (filename) | Deletes a saved .pc and its thumbnail |
M.getConfigList | () | Returns all .pc files for the current vehicle |
M.openConfigFolderInExplorer | () | Opens vehicle directory in OS file explorer |
M.sendDataToUI | () | Sends full part config data to the UI (CEF) |
M.sendPartsSelectorStateToUI | () | Sends parts selector highlight state to UI |
M.partsSelectorChanged | (state) | Debounced handler for UI part selector changes |
M.highlightParts | (parts, inVehID?) | Sets which parts are highlighted (eye icon) |
M.selectParts | (parts, inVehID?) | Temporarily highlights hovered parts at 0.2 alpha |
M.setNewParts | (inVehID?) | Merges new parts into the highlight set after config change |
M.showHighlightedParts | (inVehID?) | Re-applies current highlight alpha |
M.setHighlightedPartsVisiblity | (alpha, inVehID?) | Sets transparency of highlighted parts |
M.changeHighlightedPartsVisiblity | (deltaAlpha, inVehID?) | Changes transparency by delta |
M.resetVehicleHighlights | (onlyIfVehChanged, inVehID?) | Clears highlight data |
M.hasAvailablePart | (partName) | Returns true if the named part exists for the player vehicle |
M.setSkin | (skin) | Sets the paint_design slot to a named skin |
M.reset | () | Alias for sendDataToUI |
Hooks
| Hook | Description |
|---|---|
M.onVehicleSpawned | Invalidates rich part info cache |
M.onUpdate | Processes debounced parts selector changes |
M.onSerialize / onDeserialized | Persist/restore parts data and rich part info |
M.onDeserialized(data) | Restores part management state from save. |
M.savePartConfigFileStage2(partsCondition, filename) | Saves part config file (Format2). |
Module State
| Variable | Type | Default |
|---|---|---|
savePartConfigFileStage2 | varies | savePartConfigFileStage2_Format2 |
Usage Example
-- Save current vehicle config
extensions.core_vehicle_partmgmt.saveLocal("my_custom_config")
-- Merge new paint and respawn
extensions.core_vehicle_partmgmt.setConfigPaints({paint1, paint2, paint3}, true)
-- Check if a part exists
if extensions.core_vehicle_partmgmt.hasAvailablePart("pickup_bed_longhorn") then
log("I", "", "Part available!")
endSee Also
- Vehicle Colors - Related reference
- Vehicle In-Place Edit - Related reference
- Vehicle Manager - Related reference
- Core Systems Guide - Guide