API ReferenceGE Extensionsflowgraphnodeslogic
Flow Switch (Flowgraph Node)
- **Node Name:** `Flow Switch`
Overview
- Node Name:
Flow Switch - Category:
logic - File:
extensions/flowgraph/nodes/logic/flowSwitch.lua
A toggleable gate that controls whether flow passes through. Can be toggled by clicking in the editor, or controlled programmatically via on/off input pins.
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
flow | flow | Inflow for this node |
on | flow | Sets the switch to ON when flow arrives |
off | flow | Sets the switch to OFF when flow arrives |
Output Pins
| Pin | Type | Description |
|---|---|---|
flow | flow | Outflow (only when switch is ON and flow is present) |
Behavior
init(mgr, ...)- Initializes switch to off state.work(args)- Checkson/offinput pins to update state, then gates the flow output:flow_out = on AND flow_in.drawMiddle()- Renders a clickable checkbox icon. Clicking toggles the switch state in editor mode._executionStarted()/_executionStopped()- Restores the stored switch state (preserves editor-set toggle across runs)._onSerialize(res)/_onDeserialized(nodeData)- Persists the switch on/off state.
How It Works
The node maintains an internal on boolean. When the on input pin receives flow, the switch turns on. When the off input pin receives flow, it turns off. The output flow is only active when both the switch is on AND input flow is present.
In the editor, a checkbox icon allows manual toggling. The state set in the editor is preserved across execution start/stop cycles via storedOn.
Example Usage
-- Use as a debug toggle:
-- Click the checkbox in the editor to enable/disable a branch
-- Use as a programmatic gate:
-- Connect a "player entered area" event to the "on" pin
-- Connect a "player left area" event to the "off" pin
-- Flow only passes through while the player is in the areaSee Also
- And (Flowgraph Node) - Related reference
- Boolean Expression (Flowgraph Node) - Related reference
- Branch (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide