Select (Flowgraph Node)
- **Node Name:** `Select`
Overview
- Node Name:
Select - Category:
logic - File:
extensions/flowgraph/nodes/logic/select.lua
Selects a value from multiple choices based on which selection flow pin is active. Supports merge functions for combining multiple active selections.
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
flow | flow | Inflow for this node |
select_1 | flow | Selects value 1 |
value_1 | any | Value 1 that can be selected |
Additional
select_N/value_Npin pairs are created via the Count property.
Output Pins
| Pin | Type | Description |
|---|---|---|
flow | flow | Outflow for this node |
value | any | The selected/merged value |
Data Properties
| Property | Type | Default | Description |
|---|---|---|---|
count | number | 1 | Number of selectable value slots |
mode | string | "first" | Merge function when multiple selections are active |
Behavior
init()- Sets count to 1 and mode tofirst.work()- Iterates through all select pins. When flow is active and aselect_Npin has flow, its correspondingvalue_Nis passed to the merge function. If nothing is selected, output value is nil.updatePins(old, new)- Dynamically adds or removes select/value pin pairs.drawCustomProperties()- UI for adjusting count and selecting the merge function fromfg_utils.sortedMergeFuns.any.
How It Works
The node provides a multiplexer pattern. Each slot has a flow trigger (select_N) and a data input (value_N). When a selection flow is active, the corresponding value feeds into the merge function. The merge function (from flowgraph/utils) determines how multiple simultaneous selections combine (first, last, sum, etc.).
If no flow pin is connected at the top, the last selected value persists.
Example Usage
-- Select between two camera modes:
-- select_1 = isFirstPerson flow, value_1 = "cockpit"
-- select_2 = isThirdPerson flow, value_2 = "chase"
-- Output value = whichever mode is active
-- With merge mode "first":
-- If both are active, the first matching value winsAdditional Methods
C:_executionStarted()
Called when graph execution starts. Used for initialization/reset.
C:_onDeserialized(res)
Called after the node is deserialized (loaded from file). Restores runtime state from saved data.
Parameters:
res
C:_onSerialize(res)
Called when the node is serialized (saved to file). Returns data to persist.
Parameters:
res
C:drawMiddle(builder, style)
Custom ImGui drawing in the middle section of the node in the editor.
Parameters:
builderstyle
See Also
- And (Flowgraph Node) - Related reference
- Boolean Expression (Flowgraph Node) - Related reference
- Branch (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide