API ReferenceGE Extensionscore
Core Vehicles
Central vehicle management - model/config catalog, spawning, replacing, removing, license plates, coupler/trailer management, and vehicle collections (multi-vehicle configs).
Central vehicle management - model/config catalog, spawning, replacing, removing, license plates, coupler/trailer management, and vehicle collections (multi-vehicle configs).
Public API - Catalog
| Function | Signature | Description |
|---|---|---|
M.getModel | (key) | Returns {model, configs} for a vehicle model key |
M.getModelList | (array?) | Returns all models with filters and display info |
M.getConfigList | (array?) | Returns all configs with filters |
M.getConfig | (modelName, configKey) | Returns a specific config table |
M.getCurrentVehicleDetails | () | Returns details for the player's current vehicle |
M.getVehicleDetails | (id) | Returns details for any vehicle by id |
M.getVehicleList | () | Returns all vehicles with model data and filters |
M.createFilters | (list) | Creates filter aggregates from a list of configs/models |
M.clearCache | () | Clears all file and model caches |
M.getFilesJson | () | Returns cached list of vehicle info JSON file paths |
M.getFilesParsed | () | Returns cached table of parsed file data (JSON, PC, paint files) |
M.getPaintFiles | () | Returns cached list of .paintLibrary.json file paths |
M.getModelsData | () | Returns table of all discovered model data {info={}, configs={}} keyed by model name |
M.openSelectorUI | () | Opens the vehicle selector UI (freeroam only) |
M.openSelectorUI_legcay | () | Opens the legacy vehicle selector UI |
M.requestList | () | Sends vehicle list to CEF UI via guihooks |
M.requestListEnd | () | Finalizes the vehicle list request (stops profiler) |
M.reloadVehicle | (playerId) | Reloads the vehicle for a player; clears Steam license plate state |
M.loadCustomVehicle | (modelName, data) | Sets TorqueScript vars for custom vehicle loading |
M.convertVehicleInfo | (info, infoFilename) | Converts legacy color format to paint format; returns modified info |
M.getAttributesWhiteList | () | Returns the filter attributes whitelist array |
M.getAttributesConvertToDict | () | Returns the attributes-to-dict conversion list |
M.getAttributesConvertToRange | () | Returns the attributes-to-range conversion list |
Public API - Spawning
| Function | Signature | Description |
|---|---|---|
M.spawnNewVehicle | (modelName, opt) | Spawns a new vehicle; supports format 4 multi-vehicle configs |
M.replaceVehicle | (modelName, opt, otherVeh?, replaceWholeCollection?) | Replaces an existing vehicle or collection |
M.removeCurrent | () | Deletes the player's current vehicle |
M.cloneCurrent | () | Clones the player's vehicle with same paint |
M.removeAll | () | Deletes all vehicles |
M.removeAllExceptCurrent | () | Deletes all except the player's vehicle |
M.removeAllWithProperty | (property) | Removes all vehicles matching a property |
M.spawnDefault | () | Spawns/replaces with the default vehicle config |
M.getDefaultVehicleParams | () | Returns {modelName, opts} for the default vehicle |
Public API - License Plates
| Function | Signature | Description |
|---|---|---|
M.setPlateText | (txt, vehId?, designPath?, formats?) | Sets license plate text and generates textures |
M.makeVehicleLicenseText | (veh?, designPath?) | Generates license text from pattern or Steam name |
M.getVehicleLicenseText | (veh) | Returns current license text |
M.regenerateVehicleLicenseText | (veh) | Generates new text without applying it |
M.isLicensePlateValid | (text) | Returns false if text contains " |
Public API - Couplers & Collections
| Function | Signature | Description |
|---|---|---|
M.generateAttachedVehiclesTree | (vehId) | Builds tree of coupler-attached vehicles |
M.getCouplerOffset | (vehId, couplerTag) | Returns coupler node offsets from ref node |
M.changeMeshVisibility | (delta) | Adjusts part mesh alpha by delta |
M.setMeshVisibility | (alpha) | Sets part mesh alpha directly |
Key Fields
| Field | Description |
|---|---|
M.couplerTagsOptions | Tag → coupling behavior mapping |
M.defaultVehicleModel | "etk800" (tech) or "pickup" (game) |
Hooks
| Hook | Description |
|---|---|
M.onPreVehicleSpawned | Caches coupler nodes and offsets |
M.onVehicleSwitched | Updates player↔vehicle maps |
M.onVehicleDestroyed | Cleans up couplers, caches, and collections |
M.onCouplerAttached | Records attached coupler data |
M.onCouplerDetached | Removes detached coupler data |
M.onFileChanged | Invalidates cache on vehicle file changes |
M.onFileChangedEnd | Finalizes file change cache invalidation |
M.onSettingsChanged | Called on SettingsChanged event |
M.onSerialize | Called on Serialize event |
M.onDeserialized | Called on Deserialized event |
Module State
| Variable | Type | Default |
|---|---|---|
M.dependencies | table | { 'core_vehiclePaints' } |
M.vehiclePlayersMap | table | {} |
M.playerVehicleMap | table | {} |
M.resetVehCollectionEnabled | boolean | true |
M.vehCollections | table | Active vehicle collections keyed by main vehicle id |
M.vehIdToVehCollection | table | Maps any vehicle id to its collection |
M.initVehCollections | table | {} |
M.initVehIdToVehCollection | table | {} |
M.attachedCouplers | table | Array of {objId1, objId2, nodeId, obj2nodeId} |
M.vehsCouplerCache | table | {} |
M.vehsCouplerTags | table | {} |
M.vehsCouplerOffset | table | {} |
M.finalRanges | table | {} |
M.computeFileCacheMode | string | "batch" |
Usage Example
-- Spawn a specific config
local veh = core_vehicles.spawnNewVehicle("pickup", {
config = "vehicles/pickup/d15_4wd_A.pc"
})
-- Replace current vehicle
core_vehicles.replaceVehicle("etk800", {config = "854_190d_A"})
-- Get model info
local data = core_vehicles.getModel("pickup")
log("I", "", "Default config: " .. data.model.default_pc)
-- Set license plate
core_vehicles.setPlateText("BEAMNG", vehId)Vehicle Paints
Resolves, caches, and distributes vehicle paint data including paint libraries, paint collections, multi-paint setups, and random paint selection with weighted probability distributions.
Vehicle Triggers
Handles interactive vehicle triggers (buttons, levers, switches) that appear on vehicles. Manages cursor-based raycasting, input action binding, and a debug ImGui window.