ComfyUI Node

Ard Counter

A counter that remembers — because it writes state to disk

By ArdeniusAI·Created 2 years ago·Updated 2 years ago· 5
Ard Counter
    • x_count_int
    • x_count_float
    x_input0.00
    x_total0.00
    print_outputenabled

    Ard Counter is the pack's attempt at a loop counter: a node that keeps adding an increment to a running total until it hits a ceiling, then resets to zero. The author calls it experimental, and that label is doing real work - this is the quirkiest node in the pack, because its state doesn't live in the graph. It lives in a JSON file on disk.

    Here's the mechanism, because it changes how you use it. The node takes x_input (a float to add) and x_total (a float ceiling). Each time the node runs, it reads a JSON file the pack keeps in its own folder, adds x_input to the stored count, writes the new count back, and outputs it. When the running count reaches or exceeds x_total, it deletes the JSON file and resets to 0. So it's persistent across Queue presses in a way normal ComfyUI nodes aren't - run the graph, the count advances; run it again, it advances further. That's the whole trick, and it's also the whole trap.

    What this is for: driving the pack's experimental prompt-travel and text-box workflow, where you want a frame number that advances between runs so different prompts fire at different counts. Outputs are x_count_int and x_count_float, so you can feed either type downstream. print_output (enabled by default) spams the count to your terminal every run - disable it once you're done debugging, or you'll scroll past a lot of x count float: lines.

    Where people get burned:

    • The counter persists. Restart ComfyUI and the count picks up where it left off (the JSON survives). There's no reset button in the UI; the only in-graph reset is passing the ceiling. If your workflow gets "stuck" on a number, delete ard_data/ard_counter.json inside the pack folder.
    • The count only advances when the node runs, which means every Queue press is one increment. Batch/grid workflows advance it per queue, not per frame within a queue - a subtle mismatch that makes "one count per animation frame" harder than it looks.
    • Both inputs are floats with 0 as default. With x_total at 0, the reset branch fires immediately and you get zeros.

    Honest verdict: counters in ComfyUI are awkward because the graph is a dataflow, not a loop - there's no native "for each frame" iteration. This node papers over that with a file, and it works for simple cases. But the on-disk state makes it genuinely easy to lose track of where you are, and the "experimental" warning is accurate. If you need per-frame iteration, a proper batch/animation tool will serve you better. If you want a cheap "do this for N runs" switch inside this pack's world, it does the job - just remember where the state lives.

    Install is the standard pack route - ComfyUI Manager → search ComfyUI-Ardenius, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ArdeniusAI/ComfyUI-Ardenius
    

    then restart ComfyUI. Pack-wide notes: civitai and moviepy install with the pack, and a stray import error at startup is the Save Image node wanting comfyui_controlnet_aux - unrelated to this node.

    CategoryArdenius

    Inputs (3)

    NameTypeDefaultDescription
    x_inputFLOAT0.00input a float that increments to be added to x_count
    x_totalFLOAT0.00total a float when reached resets x_count to zeros
    print_outputoptCOMBOenabled2 options: enabled, disabled

    Outputs (2)

    NameTypeDescription
    x_count_intINT
    x_count_floatFLOAT