Nodes/comfyui-huyl2-nodes/_Loop Less Than (internal)
ComfyUI Node

_Loop Less Than (internal)

_Loop Less Than (internal)

By huyl3-cpu·Created 9 months ago·Updated 4 months ago· 1
_Loop Less Than (internal)
    • BOOLEAN
    a0
    b1

    The comparison half of the same homemade for-loop pattern as its sibling _LoopAdd - take two integers, tell you whether the first is less than the second. That's it, that's the node: a < b, returned as a boolean.

    Why it exists as a dedicated node. ComfyUI's graph has no built-in loop construct, so anyone who wants "repeat this N times" behavior ends up hand-assembling one from ordinary nodes: a counter that increments each pass (that's _LoopAdd's job) checked against a target value each time around (that's this node's job). The BOOLEAN this outputs is what actually gates whether a loop-control node elsewhere in the graph lets the next pass run or stops the whole thing. It's a pattern people rebuild from scratch constantly, in workflow after workflow, precisely because ComfyUI never shipped a native version of it.

    Inputs and outputs. a and b, both integers, defaulting to 0 and 1. One output: BOOLEAN.

    It's a genuinely tiny node, and that's sort of the point - hand-built loop scaffolding tends to be made of the smallest possible pieces, because each one has to be independently wire-able into whatever gate or switch node is actually doing the "repeat or stop" work. Nobody sets out to write a general loop framework for this; they need one specific loop for one specific workflow, and a two-node counter-plus-comparison pair is the minimum viable version of that. It's not elegant, but it's exactly enough to work, which is presumably why it exists as two tiny nodes instead of one combined "loop controller" node.

    Same caveat as _LoopAdd: the underscore prefix and the "(internal)" label mean this was built as scaffolding for a specific loop implementation elsewhere in this author's own workflows, not as a general-purpose comparison node - though there's nothing stopping you from using it standalone if all you actually need is "is a less than b" as a boolean, since that's a perfectly ordinary thing to want in any graph.

    Installing it. Same pack - search comfyui-huyl2-nodes in ComfyUI Manager, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/huyl3-cpu/comfyui-sortlist
    

    Restart ComfyUI.

    Troubleshooting. If a loop built around this node never terminates, the almost-certain cause is one of two things: whatever feeds b (the target/limit) never actually changes across passes while a's increment (from _LoopAdd) never catches up to it, or the reverse - a starts above b and the comparison is false from the very first pass, so the loop-control node downstream never even gets a "keep going" signal in the first place. Trace the actual values landing in both a and b on a couple of passes before assuming the node itself has a bug; it's a single comparison, there's nowhere in it for a logic error to hide.

    Categorycomfyui-sortlist/flow

    Inputs (2)

    NameTypeDefaultDescription
    aINT0
    bINT1

    Outputs (1)

    NameTypeDescription
    BOOLEANBOOLEAN