API ReferenceGE Extensionscorevehicle
Vehicle Colors
Manages vehicle paint colors: setting, converting, and syncing paint data.
Manages vehicle paint colors: setting, converting, and syncing paint data.
Overview
Extension: core_vehicle_colors - Provides functions to set vehicle colors by index (up to 3 paint slots), convert color strings to tables, and sync paint data with vehicle config. Handles the color format used by BeamNG's vehicle system (RGBA with 0–2 alpha range).
Public Functions
| Function | Description |
|---|---|
M.setVehicleColor(index, colorString, objID) | Sets paint by 0-based index from a color string |
M.setVehiclePaint(index, paint, objID) | Sets paint by 1-based index from a paint table |
M.colorStringToColorTable(colorString) | Converts "r g b a" string to {r,g,b,a} table (alpha mapped 0–2→0–1) |
M.onVehicleSpawned(vehId) | Syncs vehicle paint data from engine object to config |
Color String Format
"r g b a [m1 m2 m3 m4]"r, g, b: 0–1 float color componentsa: 0–2 metallic/clearcoat value (mapped to 0–1 internally)m1–m4: Optional metallic paint data
Usage Examples
-- Set primary color to red (index 0 = first paint slot)
core_vehicle_colors.setVehicleColor(0, "1 0 0 1")
-- Set paint using paint table (1-based index)
local paint = createVehiclePaint({x=0, y=0, z=1, w=1}, {})
core_vehicle_colors.setVehiclePaint(1, paint)
-- Convert color string
local color = core_vehicle_colors.colorStringToColorTable("0.5 0.5 0.5 1.0")
-- Returns {0.5, 0.5, 0.5, 0.5}Paint Slots
| Index (0-based) | Slot | Engine Property |
|---|---|---|
| 0 | Primary | veh.color |
| 1 | Secondary | veh.colorPalette0 |
| 2 | Tertiary | veh.colorPalette1 |
See Also
- Vehicle Manager - Paint color live updates