Flowgraph Manager
Top-level controller for a single flowgraph project. Manages multiple graphs (parent-child hierarchy), unique ID allocation, execution lifecycle (start/stop/pause), editor integration, node selection,
Top-level controller for a single flowgraph project. Manages multiple graphs (parent-child hierarchy), unique ID allocation, execution lifecycle (start/stop/pause), editor integration, node selection, copy/paste, serialization, and module management.
No public module exports - instantiated internally by core_flowgraphManager.
Purpose
The manager is the root object for a flowgraph. It:
- Owns all graphs, macros, and their nodes/links/pins
- Allocates globally unique IDs across the project
- Drives execution: triggers root graph, updates modules, handles hooks
- Provides editor operations: selection, clipboard, undo history
- Serializes/deserializes the entire project to/from JSON
Class (C) - Key Methods
Lifecycle
| Method | Description |
|---|---|
init(parent) | Initializes graphs, macros, modules, ID counters, execution state. |
attach(fgEditor) | Binds to the flowgraph editor UI. |
detached() | Clears selection state when editor closes. |
ID Management
| Method | Description |
|---|---|
getNextFreeGraphNodeId() | Scans all graphs/macros for an unused ID. Used for nodes and graphs. |
getNextFreePinLinkId() | Scans all pins/links for an unused ID. Counts down from 2^29. |
checkDuplicateId(id) | Debug check for ID collisions across all graphs and macros. |
getGraphNodeOffset() | Returns the current max ID offset for safe ID allocation. |
autoGraphNodeOffset() | Scans all IDs to compute the maximum used ID. |
Execution
| Method | Description |
|---|---|
start() | Begins execution: initializes modules, plans execution order, triggers executionStarted. |
stop() | Stops execution: triggers executionStopped on all modules and nodes. |
pause() / resume() | Pauses/resumes execution. |
step() | Advances one frame while paused. |
Graph Management
| Method | Description |
|---|---|
createGraph(name) | Creates a new graph in the project. |
deleteGraph(graph) | Removes a graph and its children. |
createSubgraphFromSelection(asMacro) | Groups selected nodes into a subgraph or macro. |
Editor Operations
| Method | Description |
|---|---|
copyNodes() | Copies selected nodes to clipboard. |
pasteNodes() | Pastes nodes from clipboard into current graph. |
deleteSelection() | Deletes all selected nodes and links. |
unselectAll() | Clears node and link selection. |
Key Properties
| Property | Type | Description |
|---|---|---|
id | number | Unique manager ID. |
graphs | table | {[id] = graphObj} - all graphs in the project. |
macros | table | {[id] = graphObj} - all macro graphs. |
modules | table | Ordered list of active modules (action, button, camera, etc.). |
runningState | string | "stopped", "running", or "paused". |
allowEditing | bool | Whether the editor can modify nodes/links. |
frameCount | number | Current execution frame counter. |
activity | table | Reference to the associated mission/activity, if any. |
selectedNodes | table | {[id] = true} - currently selected node IDs. |
selectedLinks | table | {[id] = true} - currently selected link IDs. |
groupHelper | GroupHelper | Helper for group/ungroup operations. |
Module System
Modules are manager-level service components sorted by moduleOrder:
-- Modules are initialized during manager setup:
-- action, aiRecording, button, camera, drift, file, foreach, level, mission, ...
-- Access a module:
local buttonModule = mgr:getModule("button")
buttonModule:addButton({ label = "Go", style = "default" })Serialization
-- Manager serializes the full project:
local data = mgr:serialize()
-- Returns: { graphs = {...}, macros = {...}, variables = {...}, ... }
mgr:deserialize(data)
-- Rebuilds all graphs, nodes, links, and modules from saved dataUsage Context
-- Managers are created/accessed via core_flowgraphManager:
local mgr = core_flowgraphManager.loadManager(filePath)
mgr:start()
-- Or get an existing running manager:
local mgr = core_flowgraphManager.getManagerByID(id)
local module = core_flowgraphManager.getManagerModule(mgrId, "camera")Additional Exports
setupStateGraph(empty)
- empty -
any - Returns:
any
createGraphAsState(name, isStateGraph)
- name -
any - isStateGraph -
any - Returns:
any
createGroupState(name)
- name -
any - Returns:
any
createStateFromLibrary(data)
- data -
any - Returns:
any
selectGraph(graph)
- graph -
any
copyGraph(oldGraph, newName, hidden)
- oldGraph -
any - newName -
any - hidden -
any - Returns:
any
convertToMacro(graph)
- graph -
any - Returns:
any
refreshIntegratedPins(node)
- node -
any
findIntegratedNode(graph)
- graph -
any - Returns:
any
updateSubgraphs(graph)
- graph -
any
updateInstances(macro)
- macro -
any
saveMacro(macro, savedata)
- macro -
any - savedata -
any
createNewMacroNode(path)
- path -
any
createInstanceFromMacro(macro, node, forceId)
- macro -
any - node -
any - forceId -
any - Returns:
any
createMacroInstanceFromPath(path, node)
- path -
any - node -
any - Returns:
any
setupCreationWorkflow()
creationWorkflow()
DrawTypeIcon(dataType, connected, alpha, typeIconSize, innercolor)
- dataType -
any - connected -
any - alpha -
any - typeIconSize -
any - innercolor -
any
deletionWorkflow()
updateEditorSelections()
findLinkIdFromHiddenLinkId(hiddenId)
- hiddenId -
any - Returns:
nil
onDragStarted()
onDrag()
onDragEnded()
dragDropTarget(payloadType)
- payloadType -
any
dragDropSource(payloadType, data)
- payloadType -
any - data -
any
goToHistory(index)
- index -
any
redo()
historySnapshot(title)
- title -
any
deleteSelectionButton()
draw(dtReal, dtSim, dtRaw)
- dtReal -
any - dtSim -
any - dtRaw -
any
getAvailableMacros()
- Returns:
any
getAvailableStateTemplates()
- Returns:
any
getAvailableNodeTemplates()
- Returns:
any
getCustomNodeTemplates()
- Returns:
table
clearGraph(graph)
- graph -
any
deleteGraphs()
getNextUniqueIdentifier()
- Returns:
any
updateEditorPosition(force)
- force -
any
updateNodePositions()
findMacrosUsedInChildren(graph, list)
- graph -
any - list -
any
findDependencyMap(serializedMacros)
- serializedMacros -
any
createSubgraphFromMacroInstance()
resolveHooksAndReset()
onUpdate(dtReal, dtSim, dtRaw)
- dtReal -
any - dtSim -
any - dtRaw -
any
logEvent(name, type, description, meta)
- name -
any - type -
any - description -
any - meta -
any
getHooklist()
- Returns:
any
getDependencies()
- Returns:
any
checkCompileWarnings()
setRunning(running, stopInstant)
- running -
any - stopInstant -
any
setPaused(paused)
- paused -
any
queueForRestart()
destroy()
getGraphByName(name)
- name -
any - Returns:
nil
resolveVariableChanges()
broadcastCall(functionName, ...)
- functionName -
any - ... -
any
broadcastCallReturn(functionName, ...)
- functionName -
any - ... -
any - Returns:
any
hasNodeForHook(functionName)
- functionName -
any - Returns:
boolean
blocksOnResetGameplay()
- Returns:
any
allNodes()
- Returns:
any
onClientEndMission()
getRelativeAbsolutePath(p, disableLogEntryOnFail)
- p -
any - disableLogEntryOnFail -
any - Returns:
any
See Also
- Flowgraph Base Module - Related reference
- Flowgraph Base State Node - Related reference
- Flowgraph Base Node - Related reference
- FlowGraph Guide - Guide
Flowgraph Link
Represents a connection between two pins in a flowgraph graph. Handles link initialization, drawing (including flow animation markers), tooltips, serialization, and quick-access conversion.
New Node Template
Template file demonstrating the structure for creating new flowgraph nodes. Shows all available pin types, node metadata fields, and the minimal `work()` entry point.