Nodes/ComfyCollectorNodes/Better Int (CCN)
ComfyUI Node

Better Int (CCN)

Better Int (CCN)

By valkymaera·Created 4 months ago·Updated 10 days ago· 1
Better Int (CCN)
    • INT
    value0
    mode
    step1
    debugfalse

    You know the ComfyUI injury: seed set to "randomize," you nail an image, you flip the dropdown to fixed - and the number in the box is already the next seed, so the good one is gone. The built-in control_after_generate fires after the run, which is exactly backwards for anyone who wants to see what just happened. Better Int (CCN) is a small integer node that lets you pick whether the change happens before or after, and keeps the widget in sync so you can pause a batch, read the number, and resume.

    How it works

    It's a primitive int with five modes, and the difference is all in the timing:

    • fixed - outputs the widget value, nothing changes.
    • increment_before / random_before - change the value, then output the new one this run. The widget updates so you see it.
    • increment_after / random_after - output the current value, then step or roll for next run. This is what the built-in randomize does, but you can also increment by a step of your choosing, not just +1.

    Random modes draw from 0 to 4294967295 - seed-sized, which makes sense for feeding a KSampler seed. The node returns NaN from its IS_CHANGED hook whenever mode isn't fixed, which is the standard trick for forcing a node to re-execute every run - the same mechanism the plumbing layer uses for anything that must fire each queue. That also means: if you stick a Better Int upstream of a big branch, you're marking everything behind it as always-dirty, so expect it to defeat caching. Fine for a batch counter, not something you want sitting in front of a chain you're iterating on.

    The inputs that matter

    value is your starting number, mode is the behavior, step is the increment amount. debug just logs mode / input / output to the console. Output is a single INT - wire it anywhere a seed or index or strength needs to change run to run. It's marked an output node, so it shows up in the results panel.

    Install

    From ComfyUI Manager, search ComfyCollectorNodes, install, restart. Or clone it:

    cd ComfyUI/custom_nodes
    git clone https://github.com/valkymaera/ComfyCollectorNodes
    

    Then restart ComfyUI. The pack has no extra Python dependencies - no pip step. Every node shows up with a (CCN) suffix, so search for CCN in the node picker to find them all.

    Where it bites

    The before/after distinction is the whole selling point, and it's also the trap: increment_after still shows you the value that just ran, same as stock ComfyUI, so if you read the widget thinking it's next-run you'll be one off. If you want "the number I see is the number I get," you want the *_before modes. Also remember the re-execution cost above - in a non-fixed mode this node never caches, so keep it out of long preview pipelines unless you actually want that.

    It's a genuinely useful little tool, and if you've been burned by the seed thing even once, it's the version of the widget you wished you had. Just pick your mode deliberately.

    CategoryCCN/utils

    Inputs (4)

    NameTypeDefaultDescription
    valueINT0-9007199254740991–9007199254740991
    modeCOMBO5 options: fixed, increment_before, increment_after, random_before, random_after
    stepINT11–1000000
    debugBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    INTINT