🎈LG_计数器
A loop counter that cycles on its own (and a None trap to know)
- count
LG_Counter (🎈LG_计数器) is the pack's answer to "I want a number that changes every time I queue." Give it a total and a direction, and each execution it hands you the next index - 0, 1, 2… then wraps back to 0. It's the little engine that drives "process every image in this batch one at a time" workflows, or anything where a different value per run changes what happens next.
Why not just use ComfyUI's own counter or a math node? Because this one is built for the loop job: it keeps per-node state across executions (it won't reset just because you re-queued), it auto-cycles so you never run off the end, it shows the current count on the node in real time, and there's a reset endpoint in the backend if you want to start over. For a fixed sequence of runs - render 10 variations, or walk through 12 reference images by index - that's the whole loop control you need.
The inputs that matter
total(INT, default 10, range 1–10000) - how many steps the counter cycles through. It counts 0 tototal-1in increase mode.mode(enum) - the direction:increase(0 → 1 → 2… then wrap),decrease(counts down, wrapping from 0 back to total), orNone. This is where the gotcha lives.
One output: count (INT), the current index, ready to feed a selector, a text node, or whatever consumes a number.
The None mode trap
None doesn't mean "stop counting" - it returns total - 1 and stays there. The README-adjacent code paths treat it as "return an index value without counting," so it's useful if you want a fixed last-index for something like "grab the final image." But if you select None expecting the counter to sit still and wait, you'll get total-1 coming out the pipe every run, which surprises people. Want counting? Pick increase or decrease. Want a stable value? Use None deliberately.
Also worth knowing: the counter state resets if you change total or mode, and a right-click reset lets you zero it out mid-run - handy when you need to restart a batch without re-queuing everything.
Installing it
Part of Comfyui_LG_Tools:
cd ComfyUI/custom_nodes
git clone https://github.com/LAOGOU-666/Comfyui_LG_Tools.git
pip install -r requirements.txt
Or via ComfyUI Manager → "Comfyui_LG_Tools" → restart. It's under Add Node → 🎈LAOGOU → Utils.
Common issues
- "The counter resets every time I re-queue." It shouldn't, as long as
totalandmodeare unchanged - those trigger a reset. If you keep changing the total between runs, that's your reset. - "I picked None and it's stuck on a number." Not a bug. That's what None does; see above.
- Pairing it with the image loader. If your goal is "load one new image per queue," you may actually want the pack's LG_ImageLoaderWithCounter instead - it bundles this exact counting logic with a folder loader so you don't have to wire the counter to an image index yourself.
It's a small node, but it's the difference between "run this 10 times by hand, changing the seed each time" and "queue it 10 times and watch it walk through your list." For batch-minded workflows, that's worth a lot.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| total | INT | 101–10000 | — |
| mode | COMBO | increase | 3 options: increase, decrease, None |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| count | INT | — |