API ReferenceGE ExtensionsuiliveryEditor
Livery Editor – Tools
Central tool manager - switches active tools, manages action maps, and dispatches operations to cursor or layer targets.
Central tool manager - switches active tools, manages action maps, and dispatches operations to cursor or layer targets.
Overview
ui_liveryEditor_tools manages which editing tool is active (transform, deform, material, mirror) and provides doOperation, the universal dispatch function that routes an operation to either the cursor (new decal) or selected layer(s).
Extension path: lua/ge/extensions/ui/liveryEditor/tools.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
useTool | (tool) | Activates a tool and its action map. Triggers LiveryEditorToolChanged. |
closeCurrentTool | () | Deactivates all action maps and clears the current tool. |
getCurrentTool | () → string | Returns the current tool name. |
applyChanges | () | Stamps the cursor as a new decal via api.addDecal(). |
doOperation | (funcOperation, ...) | Dispatches an operation function to the appropriate target(s). |
liveryEditor_editMode_onStateChanged | (data) | Hook - responds to edit mode state changes. |
Internals
Tool Constants
M.TOOLS = {
transform = "transform",
deform = "deform",
material = "material",
mirror = "mirror"
}doOperation Dispatch Logic
doOperation(fn, ...) is the core routing mechanism used by all tool modules:
- Edit mode active + reapply/apply → calls
fn(nil, ...)(operates on cursor) - Edit mode active + layer selected → calls
fn(layer, ...)(operates on the active layer) - No edit mode → iterates all selected layers and calls
fn(layer, ...)on each
M.doOperation = function(funcOperation, ...)
if M.editModeState.active then
if M.editModeState.reapplyActive or M.editModeState.applyActive then
funcOperation(nil, ...) -- cursor mode
else
local layer = api.getLayerByUid(M.editModeState.activeLayerUid)
funcOperation(layer, ...)
end
else
local selectedLayerUids = uiSelectionApi.getSelectedLayers()
if selectedLayerUids then
for _, layerUid in ipairs(selectedLayerUids) do
funcOperation(api.getLayerByUid(layerUid), ...)
end
end
end
endEdit Mode State
Synced from ui_liveryEditor_editMode via hook:
M.editModeState = {
active = nil, -- edit mode is active
reapplyActive = nil, -- reapply (stamp) mode
applyActive = nil, -- apply (new decal) mode
activeLayer = nil, -- currently edited layer
activeLayerUid = nil -- UID of the active layer
}How It Works
- The UI calls
useTool("transform")to switch tools - The appropriate action map is pushed via
ui_liveryEditor_controls - Tool-specific modules (transform, material, etc.) call
doOperation(fn, ...)for their actions doOperationroutes to cursor or layer based on the current edit mode statecloseCurrentTool()pops all action maps when the tool panel is closed
Example Usage
local tools = extensions.ui_liveryEditor_tools
-- Activate transform tool
tools.useTool("transform")
-- Dispatch a custom operation to selected layers
tools.doOperation(function(layer, value)
if layer then
layer.metallicIntensity = value
api.setLayer(layer, true)
end
end, 0.5)
-- Close tool
tools.closeCurrentTool()Additional Exports
The following exports are available but not yet documented in detail:
M.applyChangesM.closeCurrentToolM.getCurrentToolM.liveryEditor_editMode_onStateChangedM.useTool