Livery Editor – Editor (Core)
Core entry point and API interface for the livery editor UI. Manages editor lifecycle (setup, session, save, exit).
Core entry point and API interface for the livery editor UI. Manages editor lifecycle (setup, session, save, exit).
Overview
ui_liveryEditor_editor orchestrates the livery editor: initialising the dynamic decals API, toggling vehicle controls, loading/saving skin files, and cleaning up on exit. It acts as the bridge between the UI layer and editor_api_dynamicDecals.
Extension path: lua/ge/extensions/ui/liveryEditor/editor.lua
Dependencies
editor_api_dynamicDecals, ui_liveryEditor_layers, ui_liveryEditor_layers_decals, ui_liveryEditor_layers_cursor, ui_liveryEditor_camera, ui_liveryEditor_controls, ui_liveryEditor_resources, ui_liveryEditor_selection, ui_liveryEditor_tools, ui_liveryEditor_tools_transform, ui_liveryEditor_editMode
Exports (M)
| Function | Signature | Description |
|---|---|---|
setup | () | Initial API setup, switches skin to "dynamicTextures", disables vehicle controls. |
startEditor | () | Full editor initialisation (API, resources, edit mode, controls). |
startSession | () | Begins an editing session - loads a file or creates a new layer stack. |
createNew | () | Resets state so the next session starts with a blank canvas. |
loadFile | (file) → bool | Validates and queues a .dynDecals.json file for the next session. |
save | (filename) | Exports the current skin and persists the layer stack to disk. |
applySkin | () | Applies the saved skin name via core_vehicle_partmgmt.setSkin. |
exitEditor | () | Clears the layer stack, re-enables vehicle controls, resets state. |
onUpdate | () | Per-frame tick - forwards to api.onUpdate_() while the editor is running. |
Data Fields
| Field | Description |
|---|---|
M.dependencies | {"editor_api_dynamicDecals", "ui_liveryEditor_layers", "ui_liveryEditor_layers_decals", ...} - decal API and layer subsystems. |
Internals
Vehicle Controls Toggle
local function toggleVehicleControls(enable)
local commonActionMap = scenetree.findObject("VehicleCommonActionMap")
if commonActionMap then commonActionMap:setEnabled(enable) end
local specificActionMap = scenetree.findObject("VehicleSpecificActionMap")
if specificActionMap then specificActionMap:setEnabled(enable) end
endDisables driving inputs while the editor is active, re-enables on exit.
Session Flow
startEditor()- one-time setup (API, resources, edit mode, action maps)startSession()- either loads a queued file or creates a new stack with a fill layer using the vehicle's paint colour- User edits layers via other livery editor extensions
save(filename)- exports skin + saves.dynDecals.jsonapplySkin()- optionally applies the skin so it persists after exitingexitEditor()- tears everything down, restores vehicle controls
Save Filename Pattern
Only alphanumeric, dash, and underscore characters are accepted: ^[a-zA-Z0-9_-]+$
How It Works
- The editor disables vehicle action maps and the API's own update loop on start
- A fill layer matching the vehicle colour is added as the base when creating new
- Saving exports the skin via
api.exportSkin()and writes a layer stack JSON file - On exit without applying, the skin resets to
nil(default); with apply, the named skin stays
Example Usage
-- Start the editor
extensions.ui_liveryEditor_editor.startEditor()
-- Load an existing save
extensions.ui_liveryEditor_editor.loadFile("settings/dynamicDecals/mySkin.dynDecals.json")
extensions.ui_liveryEditor_editor.startSession()
-- Save and apply
extensions.ui_liveryEditor_editor.save("mySkin")
extensions.ui_liveryEditor_editor.applySkin()
-- Exit
extensions.ui_liveryEditor_editor.exitEditor()Additional Exports
The following exports are available but not yet documented in detail:
M.applySkinM.createNewM.exitEditorM.loadFileM.onUpdateM.saveM.setupM.startEditorM.startSession