π Int Switch expression
A 20-way routing valve driven by a number
- Case 0
- Case 1
- Case 2
- Case 3
- Case 4
- Case 5
- Case 6
- Case 7
- Case 8
- Case 9
- Case 10
- Case 11
- Case 12
- Case 13
- Case 14
- Case 15
- Case 16
- Case 17
- Case 18
- Case 19
- Flow
- Result
A boolean switch gives you two paths. What if you have five? Or ten? The "π Int Switch expression" is FlowNodes' answer: instead of a true/false selector, you get an integer between 0 and 19, and it picks between up to twenty inputs named Case 0 through Case 19. Whatever is in the case you selected comes out the Result socket.
The mechanism is exactly what it looks like - the code builds a dict keyed "Case N" and returns the one matching your Value:
key = "Case " + str(Value)
return (kwargs[key] if key in kwargs else None,)
So it's a big table lookup: value in, one of the cases out, everything else ignored.
When twenty cases actually earn their keep
The realistic use is a style or parameter selector with more than two states, driven by a single number:
- A seeded random pick: connect a random INT to Value, and each run draws one of ten prompt styles.
- An index from a loop: a counter feeds the switch, and each iteration of the loop routes to the next case.
- A grid/row selector:
Value = (index % 5)cycles through five resolution presets.
The case inputs are * (wildcard), so each case can be a completely different type - a string in one, a number in another. The switch doesn't care.
The pitfalls
- Value range is 0β19. The widget clamps there (default 0, min 0, max 19). If your input number exceeds the case count, you get
Noneout - which, same as the If-condition node, means "only feed this into optional/None-tolerant sockets." There's noelse/default case beyond "unconnected case β None." - Unwired case β None. Pick a case you never connected and Result is
None, not an error. Watch for the silent version of this: a value that drifts out of the wired range and quietly empties the branch. - The README's example image calls it the "Int switch" - same node, the display name just gained "expression" to match the Boolean switch's naming.
Flow input
There's an optional Flow input, part of FlowNodes' ordering system. If you're sequencing this with function nodes - e.g. the switch picks which value a write operation then mutates - route the flow through so the selection happens at the right point in the sequence. Otherwise ignore it.
Install
Part of the FlowNodes pack:
cd ComfyUI/custom_nodes
git clone https://github.com/gitmylo/FlowNodes
# restart ComfyUI
or ComfyUI Manager β search FlowNodes β install. No Python dependencies, no model downloads.
Troubleshooting
- Result is None unexpectedly - the Value is pointing at an unwired case, or is out of the 0β19 range. Check the number, then check the case socket.
- The dropdown input on Value is a widget, not a wire - right. It's a plain integer widget; convert it to an input if you want to drive it from another node.
- Need more than 20 cases - this node caps at 20 (0β19). For more, chain two switches or move the routing into an Execute Python node.
Inputs (22)
| Name | Type | Default | Description |
|---|---|---|---|
| Value | INT | 00β19 | β |
| Case 0opt | * | β | |
| Case 1opt | * | β | |
| Case 2opt | * | β | |
| Case 3opt | * | β | |
| Case 4opt | * | β | |
| Case 5opt | * | β | |
| Case 6opt | * | β | |
| Case 7opt | * | β | |
| Case 8opt | * | β | |
| Case 9opt | * | β | |
| Case 10opt | * | β | |
| Case 11opt | * | β | |
| Case 12opt | * | β | |
| Case 13opt | * | β | |
| Case 14opt | * | β | |
| Case 15opt | * | β | |
| Case 16opt | * | β | |
| Case 17opt | * | β | |
| Case 18opt | * | β | |
| Case 19opt | * | β | |
| Flowopt | FLOW | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Result | * | β |