Nodes/ComfyUI_MieNodes/Mie Loop If Current Idx ๐Ÿ‘
ComfyUI Node

Mie Loop If Current Idx ๐Ÿ‘

Branch on any comparison against the loop index

By MieMieeeeeยทCreated 2 years agoยทUpdated 28 days agoยท 225
Mie Loop If Current Idx ๐Ÿ‘
  • loop_ctx
  • then_value
  • else_value
  • loop_ctx
  • value
โ—„operator==โ–บ
โ—„compare_value0โ–บ

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, default 0) - 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_value if the comparison holds, else else_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.

Category๐Ÿ‘ MieNodes/๐Ÿ‘ Loop

Inputs (5)

NameTypeDefaultDescription
loop_ctxMIE_LOOP_CTXโ€”
operatorCOMBO==6 options: ==, !=, <, <=, >, >=
compare_valueINT0โ€”
then_valueopt*โ€”
else_valueopt*โ€”

Outputs (2)

NameTypeDescription
loop_ctxMIE_LOOP_CTXโ€”
value*โ€”