Flowgraph Button Module
Manages custom UI buttons displayed during flowgraph execution. Nodes can create, configure, and respond to button clicks through this module. Button state is sent to the UI via `guihooks.trigger('Cus
Manages custom UI buttons displayed during flowgraph execution. Nodes can create, configure, and respond to button clicks through this module. Button state is sent to the UI via guihooks.trigger('CustomFGButtons', data).
No public module exports - created via _flowgraph_createModule(C).
Purpose
Provides a button registry for flowgraph nodes. Each button has a label, style, active state, order, and click tracking. The module uses variableStorage for reactive state management and pushes button data to the UI layer each frame.
Key Methods
| Method | Signature | Description |
|---|---|---|
init | () | Creates variable storage, calls clear(). |
clear | () | Clears all buttons and variables, triggers empty button list to UI. |
addButton | (data) | Creates a button with label, style, active, and order. Returns button ID. Registers 6 variables per button (label, style, active, order, clicked, complete). |
getButton | (id) | Returns the button table for the given ID. |
set | (id, field, val) | Updates a button field (label, style, active, order) via variable storage. |
buttonClicked | (id) | Marks a button as clicked and complete. Called from UI via queueGameEngineLua. |
getCmd | (id) | Returns the Lua command string the UI calls when a button is clicked. |
afterTrigger | () | Finalizes variable changes, sends sorted active buttons to UI via guihooks, resets click flags. |
executionStopped | () | Calls clear() to remove all buttons. |
Button Data Structure
-- Internal button table (per button):
{
id = 1,
label = variableRef, -- { value = "Go!" }
style = variableRef, -- { value = "default" }
active = variableRef, -- { value = true }
order = variableRef, -- { value = 1 }
clicked = variableRef, -- { value = false }
complete = variableRef, -- { value = false }
}UI Communication
-- Buttons are pushed to the UI each frame:
guihooks.trigger('CustomFGButtons', {
{ name = "Start", fun = "local m = core_flowgraphManager.getManagerModule(1, 'button') if m then m:buttonClicked(1) end",
active = true, order = 1, style = "default" },
{ name = "Stop", fun = "...", active = true, order = 2, style = "danger" },
})
-- Buttons sorted by order, then by IDProperties
| Property | Default | Description |
|---|---|---|
moduleOrder | 0 | Standard priority. |
variables | VariableStorage | Reactive state for button properties. |
buttons | {} | Registry of button objects keyed by ID. |
buttonsChanged | true | Dirty flag to re-send button data to UI. |
Additional Exports
getFreeId()
-
Returns:
any -
idCounter-number- (see source)
See Also
- Flowgraph Action Module - Related reference
- Flowgraph AI Recording Module - Related reference
- Flowgraph Camera Module - Related reference
- FlowGraph Guide - Guide
Flowgraph AI Recording Module
Handles recording and replaying AI vehicle scripts during mission execution. Used for mission testing - records the player's driving as an AI path, then saves it alongside mission test data.
Flowgraph Camera Module
Manages camera path playback for flowgraph projects. Loads, stores, plays, and cancels camera paths. Used for cinematic sequences, mission intros, and scripted camera movements.