Nodes/ComfyUI Logic Support/Boolean Index Adder
ComfyUI Node

Boolean Index Adder

First true wins, and it becomes a number

By narusas·Created about a year ago·Updated about a year ago· 0
Boolean Index Adder
    • I
    base_number0
    bool1false
    bool2false
    bool3false
    bool4false
    bool5false
    bool6false
    bool7false
    bool8false
    bool9false
    bool10false
    bool11false
    bool12false
    bool13false
    bool14false
    bool15false

    Somewhere in a workflow you usually end up with a pile of true/false flags - "is a face detected," "did this check pass," "is this batch index odd" - and you want a single number out of them so the rest of the graph can act on it. Boolean Index Adder is that translation. It looks at up to 15 boolean inputs, finds the first one that's true, and adds its position (1-based) to a base_number. No true flags at all? You just get base_number back unchanged.

    So with base_number 10 and bool2 set true, you get 12. With bool4 true and base 0, you get 4. The README's own example: base 10, bool1 false, bool2 true, bool3 false → 12.

    The inputs are exactly what they sound like: base_number (an INT, default 0) and bool1 through bool15 (BOOLEAN, default false). The sockets all show up whether you wire them or not, and unwired ones just sit at false - so a mostly-empty node behaves. The single output is an INT: base_number plus the winning index.

    The clever use is choosing between options by condition rather than by hand. Say you have three quality gates and you want a different prompt for whichever one fired. Wire each gate to a bool slot, set base_number to 0, and the output becomes the number of the first passing gate - feed that straight into a String Switch By Number node (same pack) and you've got condition-driven text selection with no Python.

    A couple of honest catches. It's "first true," not "count the trues" - if you need to know how many flags are set, this node isn't it, and nothing else in the pack does that either. And because the index is 1-based, slot 1 gives you base+1, not base. Plan your base_number around that and you'll be fine.

    Installing this pack is a one-liner, same for every node in it:

    cd ComfyUI/custom_nodes
    git clone https://github.com/narusas/Comfyui-Logic-Support
    

    Restart ComfyUI after (or refresh the page), or grab it through ComfyUI Manager by searching "ComfyUI Logic Support." No dependencies, no model files, no API keys - it's pure Python under the hood, so it can't drag your environment into the dependency conflicts that plague bigger node packs. It's a small, MIT-licensed pack from a single author; don't expect a big community around it, just expect the nodes to work.

    CategoryLogic-Support

    Inputs (16)

    NameTypeDefaultDescription
    base_numberINT0
    bool1BOOLEANfalse
    bool2BOOLEANfalse
    bool3BOOLEANfalse
    bool4BOOLEANfalse
    bool5BOOLEANfalse
    bool6BOOLEANfalse
    bool7BOOLEANfalse
    bool8BOOLEANfalse
    bool9BOOLEANfalse
    bool10BOOLEANfalse
    bool11BOOLEANfalse
    bool12BOOLEANfalse
    bool13BOOLEANfalse
    bool14BOOLEANfalse
    bool15BOOLEANfalse

    Outputs (1)

    NameTypeDescription
    IINT