Mie Loop If Current Idx ๐
Branch on any comparison against the loop index
- loop_ctx
- then_value
- else_value
- loop_ctx
- value
The general-purpose branch of the loop family. Where MieLoopIfIsFirst and MieLoopIfIsLast only cover the two endpoints, MieLoopIfCurrentIdx compares the current iteration index against any number you pick, with any operator - and outputs one value or the other based on the result.
Part of ComfyUI-MieNodes (ComfyUI_MieNodes), MieMieeeee's utility pack, under the ๐ Loop submenu.
Why you'd reach for it
Sometimes "first" and "last" aren't the boundary you care about. You want to change behavior after the third pass, do something every time before the halfway mark, skip a step on iteration 5. This node handles all of those: pick an operator, pick a value, and it evaluates index <operator> compare_value and routes accordingly. It's the if index >= n you'd write in code, as one node.
Think warm-up passes (do cheap work while index < 3, then switch to full quality), staged prompts (swap the guidance once you're past a threshold), or gating an expensive branch to only fire on specific iterations.
The inputs and outputs that matter
loop_ctx(MIE_LOOP_CTX) - the loop context, source of the index.operator- one of==,!=,<,<=,>,>=. The comparison to run. Default==.compare_value(INT, default0) - the number the index is tested against.then_value(any type, optional) - output when the comparison is true.else_value(any type, optional) - output when it's false.
Outputs:
loop_ctx- passed through to keep the loop chain going.value(any type) -then_valueif the comparison holds, elseelse_value.
Remember the index is 0-based: the first pass is 0. So >= 3 first becomes true on the fourth iteration. Both value inputs are wildcard *, so this switches any type.
Installing it
ComfyUI Manager โ search ComfyUI-MieNodes โ install โ restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MieMieeeee/ComfyUI-MieNodes
then restart. No model downloads or heavy dependencies. Under ๐ MieNodes โ ๐ Loop.
Common issues
Off-by-one on the comparison. The index starts at 0. If you meant "on the third pass," that's index == 2, not == 3. Count from zero.
It's really just first/last. If your comparison is == 0 or "the final pass," the dedicated MieLoopIfIsFirst / MieLoopIfIsLast nodes are clearer and don't need you to know the count. Use this for everything in between.
Both branches compute. As with the other If nodes, this selects an output; it doesn't prune the unselected branch's upstream. Expensive work hanging off the untaken branch still runs.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| loop_ctx | MIE_LOOP_CTX | โ | |
| operator | COMBO | == | 6 options: ==, !=, <, <=, >, >= |
| compare_value | INT | 0 | โ |
| then_valueopt | * | โ | |
| else_valueopt | * | โ |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| loop_ctx | MIE_LOOP_CTX | โ |
| value | * | โ |