Nodes/deforum-comfy-nodes/Lazy Index Switch | Deforum
ComfyUI Node

Lazy Index Switch | Deforum

Pick a branch by number

By deforum·Created about a year ago·Updated 3 months ago· 29
Lazy Index Switch | Deforum
  • value0
  • value1
  • value2
  • value3
  • value4
  • value5
  • value6
  • value7
  • value8
  • value9
  • *
index0

If Lazy Conditional | Deforum is the if/elif/else chain, Lazy Index Switch | Deforum is the switch statement: you feed it a number, it returns the matching value, and only that value's upstream actually runs. Same lazy trick, different control surface - and for animation, the index version is often the more natural fit, because animations are full of things that are already numbers.

The inputs are index (an INT from 0 to 9, default 0) and up to ten values, value0 through value9. value0 is required; the rest are optional wildcard sockets. The output is the value at the index you asked for. Drive index from a per-frame counter or a schedule and you've got a per-frame branch selector - frame 0 uses value0, frame 5 uses value5, no recomputation of the branches you skipped.

That last part is why you'd pick this over a plain old selector. Because the inputs are marked lazy, ComfyUI's engine asks the node which input it actually needs before executing anything behind it. So you can load ten different models, or ten conditioning stacks, or ten prompt presets, and the index simply determines which one gets computed for that frame. In a loop that's the difference between one clean branch running per iteration and ten branches hammering your VRAM every single frame. The tradeoff, same as its conditional sibling, is that an unselected branch is never validated - you won't discover it's broken until the index lands on it.

The classic pattern in this pack's own world: wire index from a Value Schedule | Deforum output (its INT socket), and use the switch to flip between prompt branches, LoRA stacks, or even whole style subgraphs as the animation progresses. Since the values are wildcard-typed you can switch over any data type, not just models. Ten slots is the hard ceiling, and index is clamped 0–9, so if you need more branches you chain a second switch or reach for the conditional instead.

One quirk worth knowing: the index is a plain integer input, not forced to a socket the way the conditional's booleans are, so you can type a constant if you just want a manual A/B/C picker. But its real home is wired to something that changes per frame.

Installation is the pack, not this node alone - deforum-comfy-nodes ships all of these together. ComfyUI Manager, search "ComfyUI-Deforum" or deforum-comfy-nodes, install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/deforum-art/deforum-comfy-nodes, then restart. No model files, no extra dependencies, and it used to live at XmYx/deforum-comfy-nodes before the repo moved to the deforum-art org, in case old workflow files point you at the old URL.

CategoryDeforum/Logic

Inputs (11)

NameTypeDefaultDescription
indexINT00–9
value0*
value1opt*
value2opt*
value3opt*
value4opt*
value5opt*
value6opt*
value7opt*
value8opt*
value9opt*

Outputs (1)

NameTypeDescription
**