Nodes/comfyui-lopi999-nodes/Advanced Text Switch
ComfyUI Node

Advanced Text Switch

Ten prompt slots with weighted random picks, for artist-mix chaos

By LaVie024·Created 2 years ago·Updated 10 months ago· 8
Advanced Text Switch
    • text
    ◄modeindex►
    ◄index0►
    ◄seed0►
    ◄text_0►
    ◄prob_01►
    ◄text_1►
    ◄prob_11►
    ◄text_2►
    ◄prob_21►
    ◄text_3►
    ◄prob_31►
    ◄text_4►
    ◄prob_41►
    ◄text_5►
    ◄prob_51►
    ◄text_6►
    ◄prob_61►
    ◄text_7►
    ◄prob_71►
    ◄text_8►
    ◄prob_81►
    ◄text_9►
    ◄prob_91►
    ◄concat_text►

    The author built this one with a very specific workflow in mind: swapping artist mixes at random when using Illu/NoobAI models. The stock text switch picks between a couple of text inputs; AdvancedTextSwitch gives you ten multiline textboxes, an index or weighted-random mode, and an optional concat_text that prefixes whatever gets chosen. It's the "variety without duplicates" node for people who batch-generate and want every image to pull a different style from a curated pool.

    Why you'd reach for it

    If you're doing anime batches, the artist-mix game is real: you keep a list of "Hokusai + ukiyo-e," "Makoto Shinkai background style," and so on, and you want each generation to grab one at random instead of you manually cycling them. Ten slots is a lot of variety. The weighted mode is the standout - each slot has a prob_N weight, so you can make your favorite mix show up three times as often as the experimental one without deleting the experiment. And concat_text lets you prepend a fixed base prompt to whichever slot wins, so the random part only swaps the style tail.

    How it works

    Two modes, from the source. In index mode it's a plain switch: the index input (0-9) selects which text_N comes out. In random mode it seeds a random choice, builds a weighted list by repeating each non-empty text prob_N times, and picks from it - so a slot with weight 3 is three times more likely. If concat_text is non-empty, the output becomes concat_text, selected. One quirk worth knowing: in random mode, a slot with prob_N of 0 or an empty text is excluded entirely, so weights double as an on/off switch.

    The author's honest confession in the README: the unused textboxes don't hide like they should - a ComfyUI feature that resisted implementation. It's cosmetic, not functional, but the node takes up vertical space with ten always-visible text areas.

    The inputs that matter

    • mode (enum) - index or random. This is the first thing to set.
    • index (INT, 0-9) - which slot wins in index mode.
    • seed (INT) - reproducibility for random mode.
    • text_0 through text_9 (multiline STRING) - your pool. Ten slots.
    • prob_0 through prob_9 (INT, default 1) - weights in random mode.
    • concat_text (STRING, optional) - prepended to the winner.
    • text (STRING) - the output, wired into your prompt/CLIP text encoder.

    Installing it

    cd ComfyUI/custom_nodes
    git clone https://github.com/LaVie024/comfyui-lopi999-nodes
    

    Restart ComfyUI, or find "comfyui-lopi999-nodes" in ComfyUI Manager. No model downloads, no dependencies.

    Common issues

    The visible-textboxes thing will bug you at first, and there's no fix - it's the author's known limitation. In random mode, remember the seed controls the pick: a fixed seed means the same slot wins every run, which is often mistaken for a bug. And if concat_text is set but a slot is empty, the output is just concat_text - so a zero-weight slot still produces output. Keep weights and texts consistent or you'll get mysterious half-prompts.

    Categorylopi999/string

    Inputs (24)

    NameTypeDefaultDescription
    modeCOMBOindex2 options: index, random
    indexINT00–9—
    seedINT00–18446744073709550000—
    text_0STRING—
    prob_0INT1—
    text_1STRING—
    prob_1INT1—
    text_2STRING—
    prob_2INT1—
    text_3STRING—
    prob_3INT1—
    text_4STRING—
    prob_4INT1—
    text_5STRING—
    prob_5INT1—
    text_6STRING—
    prob_6INT1—
    text_7STRING—
    prob_7INT1—
    text_8STRING—
    prob_8INT1—
    text_9STRING—
    prob_9INT1—
    concat_textoptSTRING—

    Outputs (1)

    NameTypeDescription
    textSTRING—