API ReferenceGE Extensionsflowgraphnodesstates
State Node (Flowgraph Node)
- **Node Name:** `State Node`
Overview
- Node Name:
State Node - Category: (default)
- File:
extensions/flowgraph/nodes/states/stateNode.lua - Hidden: Yes
Represents a state in a state-machine flowgraph. Each state node references a target graph that it encapsulates. Can contain sub-graphs (group states).
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
flow | state | State flow pin |
Output Pins
| Pin | Type | Description |
|---|---|---|
success | state | Success transition |
fail | state | Failure transition |
Custom state output pins can be added manually (allowCustomOutPins = true).
Behavior
init(mgr)- Enables custom output pins and pin saving.setTargetGraph(graph)- Assigns the target graph this state node represents. Updates the node name and color (usesgroupstatecolor if the target is itself a state graph).representsGraph()- Returns the target graph (used by the editor to identify graph ownership).doubleClicked()- Navigates the editor into the target graph.getTransitionNames()- Returns sorted list of all output pin names (used by Transition nodes for their dropdown).drawMiddle()- Displays graph name, marks group states, and highlights when active.
Serialization
_onSerialize(res)- SavestargetGraphId._onDeserialized(data)- RestorestargetGraphId._postDeserialize()- ResolvestargetGraphIdto an actual graph reference using the manager's graph offset._onSerializeState()- Exports the full state (node + graph data) for saving as.state.flow.json.
Editor Integration
drawCustomProperties()- Combo box to select target graph from root-level graphs. Includes "Export State" button that saves to.state.flow.json.onCustomNameChanged(name)- Renames the target graph when the node is renamed.
How It Works
- A state node wraps a sub-graph. When the state is active, the sub-graph runs.
- Output pins define possible transitions (e.g.
success,fail, custom names). - Transition nodes inside the sub-graph trigger these exits.
- The state manager tracks which state is active and handles transitions between state nodes.
-- State nodes are created via the special factory:
return _flowgraph_createStateNode(C)
-- The editor displays a combo for selecting which graph this state represents
-- Double-clicking navigates into the referenced graphKey Dependencies
ui_flowgraph_editor- Node colors, icons, and tooltip utilitiesui_imgui- ImGui bindings for editor UIextensions.editor_fileDialog- File save dialog for state export
Additional Methods
C:EndPin()
Node method.
C:setAutoStart(val)
Node method.
Parameters:
val
See Also
- State Entry (Flowgraph State Node) - Related reference
- State Exit (Flowgraph State Node) - Related reference
- Transition (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide