API ReferenceGE Extensionscore
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.
Resolves, caches, and distributes vehicle paint data including paint libraries, paint collections, multi-paint setups, and random paint selection with weighted probability distributions.
Public API
| Function | Signature | Description |
|---|---|---|
M.setupPaints | (model, configs) | Resolves all paints for a model: library paints, collections, multi-paint setups, and per-config defaults |
M.getRandomPaints | (model_key, config_key) | Returns a random paint result {type, paintName1, paintName2, paintName3} using weighted distribution |
M.getRandomPaintsByVehicle | (vehId) | Returns {paintName1, paintName2, paintName3} for an existing vehicle |
M.testRandomPaint | (model_key, config_key, amount) | Logs paint distribution statistics for testing |
Internal Functions
| Function | Description |
|---|---|
getPaintById(id) | Returns a paint from the global cache by id |
getPaintCollectionById(id) | Returns a paint collection by id |
buildPaintCaches() | Parses all .paintLibrary.json files and caches paints, collections, and multi-paint setups |
resolvePaintHelper(...) | Resolves a paint key/object to an actual paint, adding to model if needed |
resolveMultiPaintSetupHelper(...) | Resolves a multi-paint setup (3 paint slots) |
setupRandomPaintHelper(model_key) | Builds weighted random paint distribution for model + configs |
Paint Resolution Order
- Direct name match in
model.paints - ID lookup in paint library cache
- Name lookup in paint library cache (with warning)
Usage Example
-- Get random paints for traffic spawning
local paints = core_vehiclePaints.getRandomPaints("pickup", "d15_4wd_A")
-- paints = {type="paint", paintName1="Red", paintName2="Red", paintName3="Red"}
-- Or by existing vehicle
local paintNames = core_vehiclePaints.getRandomPaintsByVehicle(vehId)
-- paintNames = {"Metallic Blue", "Metallic Blue", "Metallic Blue"}
-- Test distribution (logs to console)
core_vehiclePaints.testRandomPaint("pickup", "d15_4wd_A", 10000)Vehicle Mirrors
Renders vehicle mirror reflections by computing reflection camera transforms from mirror node positions and the player camera.
Core Vehicles
Central vehicle management - model/config catalog, spawning, replacing, removing, license plates, coupler/trailer management, and vehicle collections (multi-vehicle configs).