RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Ambient SoundUI Apps ManagerUI AudioBindings LegendCamera Distance AppDeveloper ConsoleCredits MusicExternal WebSocket ServerFade ScreenGame BlurGameplay App ContainersGrid SelectorLivery EditorMessages DebuggerMessages/Tasks App ContainersMission InfoPolice InfoTop BarUI ModsNavigation Map DataVehicle Paint EditorVehicle Vicinity AppUI Visibility
Camera ManagementAction Map ManagementEdit Mode State MachineLivery EditorUndo/Redo WrapperLayer ActionsLayer Edit LifecycleLayer DataDecal Texture LoaderLayer SelectionToolsLivery FilesMath Utilities

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE ExtensionsuiliveryEditor

Edit Mode State Machine

Edit mode state machine for the livery editor - manages layer application, reapplication, selection, and undo within an editing session.

Edit mode state machine for the livery editor - manages layer application, reapplication, selection, and undo within an editing session.


Overview

ui_liveryEditor_editMode controls the state machine for applying, reapplying, and managing decal layers during an active livery editing session. It tracks applied layers, handles cursor properties, and provides save/cancel operations.

Extension path: lua/ge/extensions/ui/liveryEditor/editMode.lua

Note: This file is entirely commented out in the current codebase, indicating it is either deprecated, in development, or being refactored. The documented API reflects the commented implementation.


Commented API

State Fields

FieldTypeDescription
activebooleanWhether edit mode is currently active.
applyActivebooleanWhether a new decal application is pending.
reapplyActivebooleanWhether reapplying an existing layer.
allowApplybooleanWhether apply action is permitted.
activeLayerUidstringUID of the currently selected layer.
appliedLayerstableList of layer UIDs applied in this session.
isDuplicateActiveLayerbooleanFlag during layer duplication.

Core Functions

FunctionDescription
activate()Enters edit mode, pushes action map, starts apply request.
deactivate()Exits edit mode, clears state, pops action map.
apply()Applies current decal if allowed.
onApply(layer)Callback after decal application - handles continuous/single apply.
requestApply()Starts a new apply operation.
cancelRequestApply()Cancels pending apply.
requestReapply()Begins reapplying an existing layer (disables original).
cancelReapply()Cancels reapply, re-enables original layer.
saveChanges(params)Finalizes applied layers, optionally grouping them.
cancelChanges()Removes all applied layers and resets state.

Layer Management

FunctionDescription
setActiveLayer(uid)Selects a layer, updates highlighting and UI.
setActiveLayerDirection(dir)Navigates between applied layers (+1/-1).
duplicateActiveLayer()Creates a copy of the active layer.
removeAppliedLayer(uid)Removes a layer and updates applied list.
getActiveLayer()Returns the current active layer data.
toggleHighlightActive()Toggles decal highlighting on the active layer.

Internals

State Machine Flow

deactivate → activate → requestApply → apply → onApply
                                                  ↓
                                        (continuous) → cursor stays active
                                        (single)    → setActiveLayer → edit/reapply
                                                  ↓
                                        requestReapply → apply → onApply → setActiveLayer
                                                  ↓
                                        saveChanges / cancelChanges → deactivate

Continuous vs Single Apply

When api.isUseMousePos() is true (mouse projection), apply is continuous - each click adds a decal and the cursor stays active. In cursor mode, apply is single-shot and selects the new layer.

Layer Grouping

saveChanges({grouped = true}) creates a linked set and moves all applied layers into it:

local group = api.addLinkedSet()
for k, v in ipairs(M.appliedLayers) do
  api.moveLayer(lastPos, nil, index, group.uid)
end

Hooks

HookDescription
liveryEditor_OnLayerAddedTracks new layers, handles reapply replacement.
liveryEditor_onLayersUpdatedUpdates highlighting when layers change.
liveryEditor_editMode_onStateChangedBroadcasts state changes to other modules.

How It Works

  1. User enters edit mode → activate() pushes action map and starts apply
  2. Decal cursor becomes visible, user positions and clicks to apply
  3. onApply records the layer and either continues or enters selection
  4. User can reapply (modify position of existing layer) or add more
  5. saveChanges finalizes; cancelChanges removes all applied layers
  6. deactivate clears everything and restores normal mode

Additional Exports

The following exports are available but not yet documented in detail:

  • M.activate
  • M.active
  • M.activeLayerUid
  • M.allowApply
  • M.apply
  • M.applyActive
  • M.cancelChanges
  • M.cancelReapply
  • M.cancelRequestApply
  • M.deactivate
  • M.duplicateActiveLayer
  • M.editModeStateChanged
  • M.getActiveLayer
  • M.getAppliedLayersData
  • M.highlightTimer
  • M.isApplyActive
  • M.isContinuousApply
  • M.isDuplicateActiveLayer
  • M.isReapplyActive
  • M.lastLayerPosition
  • M.liveryEditor_OnLayerAdded
  • M.liveryEditor_OnLayerDeleted
  • M.liveryEditor_onLayersUpdated
  • M.onApply
  • M.onUpdate
  • M.reapplyActive
  • M.removeAppliedLayer
  • M.requestApply
  • M.requestReapply
  • M.resetCursorProperties
  • M.saveChanges
  • M.setActive
  • M.setActiveLayer
  • M.setActiveLayerDirection
  • M.setAllowApply
  • M.setAppliedLayers
  • M.setApplyActive
  • M.setReapplyActive
  • M.setup
  • M.toggleHighlightActive
  • M.toggleRequestApply

See Also

  • Livery Editor - Camera - Related reference
  • Livery Editor - Controls - Related reference
  • Livery Editor – Editor (Core) - Related reference
  • UI System Guide - Guide

Action Map Management

Action map management for the livery editor - handles input mode switching between transform, rotate, scale, and stamp modes.

Livery Editor

Core entry point and API interface for the livery editor UI. Manages editor lifecycle (setup, session, save, exit).

On this page

OverviewCommented APIState FieldsCore FunctionsLayer ManagementInternalsState Machine FlowContinuous vs Single ApplyLayer GroupingHooksHow It WorksAdditional ExportsSee Also