API ReferenceGE ExtensionsuiliveryEditorlayers
Livery Editor – Layers / Fill
Manages fill layers - solid colour backgrounds that serve as the base coat in a livery.
Manages fill layers - solid colour backgrounds that serve as the base coat in a livery.
Overview
ui_liveryEditor_layers_fill handles creation, colour editing, saving/restoring, and data requests for fill layers. Fill layers use a colorPaletteMapId system where 0 means custom colour and non-zero means the vehicle's default paint.
Extension path: lua/ge/extensions/ui/liveryEditor/layers/fill.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
setLayer | (layerUid) | Sets the active fill layer UID and caches a deep copy. |
changeColor | (color) | Changes the fill colour. Accepts RGB (3) or RGBA (4) arrays. Sets colorPaletteMapId to 0. |
addLayer | (params) → layer | Adds a new fill layer. If params.color is given, uses custom colour. |
updateLayer | (params) | Updates the active layer's colour. |
saveChanges | () | Commits current state by re-caching the layer data. |
restoreLayer | () | Restores the layer to its last saved/cached state. |
restoreDefault | () | Resets colorPaletteMapId to 1 (vehicle default paint). |
requestLayerData | () | Sends fill layer data to the UI via liveryEditor_fill_layerData. |
Internals
Color Palette Map ID
0- custom colour (user-editable)1+- vehicle default paint colour (read fromgetPlayerVehicle(0).color)
When adding a new fill layer with colorPaletteMapId == 0, the module sets the initial colour to the current vehicle paint colour.
changeColor
M.changeColor = function(color)
local layer = api.getLayerByUid(M.layerUid)
if layer.colorPaletteMapId ~= 0 then
layer.colorPaletteMapId = 0 -- switch to custom
end
layer.color = Point4F.fromTable(color)
api.setLayer(layer, true)
endHow It Works
addLayer({color = vehicleObj.color})creates the base fill with the car's paintchangeColor({r, g, b})sets a custom colour, overriding the paletterestoreDefault()reverts to palette ID 1 (vehicle paint)requestLayerData()sends the current colour to the UI for the colour picker
Example Usage
local fill = extensions.ui_liveryEditor_layers_fill
-- Add a white fill layer
local layer = fill.addLayer({ color = {1, 1, 1, 1} })
-- Change to red
fill.setLayer(layer.uid)
fill.changeColor({1, 0, 0, 1})
-- Restore to vehicle default
fill.restoreDefault()Additional Exports
The following exports are available but not yet documented in detail:
M.addLayerM.layerDataM.requestLayerDataM.restoreDefaultM.restoreLayerM.saveChangesM.setLayerM.updateLayer