Nodes/fxai-toolkit/凤希AI - 循环控制器
ComfyUI Node

凤希AI - 循环控制器

A loop controller that keeps your segment loop honest

By fxai666·Created 4 months ago·Updated 3 days ago· 35
凤希AI - 循环控制器
    • 开始索引
    • 结束索引
    • 总循环数
    开始索引0
    结束索引-1
    总循环数10

    FxAiStartEndIndex ("凤希AI - 循环控制器") is the guardrail for the pack's segment-loop workflow. You tell it where to start, where to stop, and how many iterations you planned; it clamps everything into a valid range and hands back the numbers a loop actually needs. If you've ever had a batch run scream past the end of your storyboard and crash mid-render, this is the node that was supposed to stop you.

    What it does

    The whole fxai-toolkit philosophy is "generate a little, loop a lot": each iteration produces one short segment, and you drive that loop with index counters. This node is where you define the bounds of that loop once, so you don't re-type the range in three places (and don't drift between them). It's classic plumbing - the comfyui-node-plumbing crowd would call it a value-and-clamp node, and they'd be right.

    Here's the behavior, straight from the source:

    • 开始索引 gets clamped to [0, 总循环数 - 1]. Type 7 when you only have 5 scenes and you get 4, not a crash.
    • 结束索引 defaults to -1, which means "run to the end." Set it to -1 and the node fills in 总循环数 - 1 for you.
    • It then reports the real loop count: 结束索引 - 开始索引 + 1. That's the number to feed your actual loop iterator, and it's always correct even when you've misplanned the range.

    The inputs and outputs that matter

    • 开始索引 - INT, default 0, range 0–999.
    • 结束索引 - INT, default -1. The -1 = to the end convention is the one thing worth memorizing here.
    • 总循环数 - INT, default 10, range 1–999. Your planned iteration budget.

    Outputs are three INTs, all named after the inputs: 开始索引, 结束索引, and 总循环数 (which now holds the computed real count, not your raw input). Wire those into your loop's index trackers.

    Why you'd reach for it over raw primitives

    A plain PrimitiveInt can hold a number fine, but it can't compute one. The value here is that the loop count is derived from a real start/end range - so when you shorten a storyboard from 12 shots to 8, this node recalculates instead of silently over-iterating. That single behavior is the difference between a workflow that survives editing and one that throws index-out-of-range mid-batch.

    Install and the honest caveats

    Standard pack install:

    cd ComfyUI/custom_nodes
    git clone https://github.com/fxai666/fxai-toolkit
    

    Then restart ComfyUI (or use ComfyUI Manager, search "fxai-toolkit").

    Caveat worth knowing: this node doesn't drive the loop. It computes and clamps - the loop itself is still whatever loop node your workflow uses. If your loop doesn't read its outputs, the clamping never happens and you're back to manual index wiring. Wire it properly and it's the kind of node you forget exists, which is the nicest thing a loop controller can do.

    Category凤希AI/工具

    Inputs (3)

    NameTypeDefaultDescription
    开始索引INT00–999
    结束索引INT-1-1–999
    总循环数INT101–999

    Outputs (3)

    NameTypeDescription
    开始索引INT
    结束索引INT
    总循环数INT