API ReferenceGE Extensionsflowgraphnodestypes
Set Variable (Flowgraph Node)
- **Node Name:** `Set Variable`
Overview
- Node Name:
Set Variable - Category:
repeat_instant - File:
extensions/flowgraph/nodes/types/setVariable.lua - Icon:
cloud_upload - Hidden: Yes (created via variable system, not node palette)
Writes a value to a flowgraph variable (graph-local or project-global) through a dynamically typed input pin.
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
flow | flow | Execution flow |
| (dynamic) | (matches variable type) | Value to write to the variable |
Output Pins
| Pin | Type | Description |
|---|---|---|
flow | flow | Passes through input flow |
The input pin is created dynamically based on the selected variable's name and type.
Internals
| Field | Purpose |
|---|---|
self.varName | Name of the selected variable |
self.global | true = writes to project-level variables; false = graph-local |
self.target | Reference to the variable store |
How It Works
init()- SetsvarName = nil, defaults to local graph variables.setGlobal(global)- Switches variable target between graph-local and project-global. Removes the current input pin and resetsvarName.setVar(name)- Looks up the variable, removes the old input pin, creates a new pin matching the variable's type, and reconnects compatible links.work()- Callsself.target:change(varName, value)to update the variable, then passes flow through.renameVariable(source, name, newName)- Handles variable renames from the variable system.typeUpdated(source, name, newType)- Recreates the input pin when the variable type changes.drawMiddle()- Shows the current variable value inline or???if missing.
Serialization
- Saves
varNameandglobalflag. - On deserialization, calls
setGlobal()thensetVar()to rebuild the pin.
Example Usage
-- In the flowgraph editor, this node is created automatically when
-- you drag a variable from the variable panel as a "setter".
-- Equivalent runtime behavior:
self.graph.variables:change("myVar", newValue)Additional Methods
C:_onDeserialized(nodeData)
Called after the node is deserialized (loaded from file). Restores runtime state from saved data.
Parameters:
nodeData
C:_onSerialize(res)
Called when the node is serialized (saved to file). Returns data to persist.
Parameters:
res
C:drawCustomProperties()
Custom ImGui drawing for the node's properties panel in the editor.
See Also
- Bool (Flowgraph Node) - Related reference
- Color (Flowgraph Node) - Related reference
- Generic Set/Get Variable (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide