Nodes/MF-PipoNodes/MF Line Select
ComfyUI Node

MF Line Select

The node that turns a prompt list into a cycling selection — by index

By MomentFactory·Created 11 months ago·Updated 7 months ago· 1
MF Line Select
    • selected_line
    text
    line_index0

    You've got a list of prompts - one per scene, one per style, one per concept - and you want the workflow to pick one and move on. That's the entire job of MF Line Select (MF_LineSelect): take multiline text and an index, return the line at that position. It's the plumbing behind half the batch patterns in the MF PipoNodes pack (pierreb-mf / Moment Factory), and it's dead simple to understand.

    How it works

    Two required inputs:

    • text (multiline) - your list, one item per line.
    • line_index - which line to return, 0-based (0 is the first line), from 0 to 1000.

    One output: selected_line (STRING).

    Indexing is 0-based, so with "forest\nbeach\nmountain\ncity", index 2 returns "mountain". The split logic normalizes \r\n and \r to \n first, and - consistent with MF Line Counter - empty lines are counted as lines. So if your list has blank separators, they occupy indices and shift everything after them.

    Where the trap is

    The important behavior is what happens out of range: the node doesn't error or halt. It prints a warning to the console and returns the warning string itself as selected_line:

    ⚠️ Line index 5 out of range (0-3)
    

    So if you feed an index that's too big into a text encoder, you don't get a crash - you get a prompt that literally contains the words "Line index 5 out of range." That is a silent-failure trap of the first order, and it's the #1 way this node will bite you. Guard it with MF Line Counter (compare line_count_int against your index) or drive the index with MF Modulo Advanced so it wraps instead of overflowing.

    The pattern that makes it shine

    The classic setup, straight from the pack's README, is cycling prompts through a batch:

    Step counter ──▶ MF Modulo Advanced (mod 5) ──▶ line_index
                                                          │
    5 prompts (text) ────────────────────────────▶ MF Line Select
                                                          │
                                                          ▼
                                                     Text encode → KSampler
    

    Modulo gives you 0,1,2,3,4 forever, so the list wraps cleanly no matter how long the batch runs. Add MF Dice Roller to the index instead and the same node becomes a random-prompt picker.

    Install

    cd ComfyUI/custom_nodes/
    git clone https://github.com/pierreb-mf/ComfyUI-MF-PipoNodes
    cd ComfyUI-MF-PipoNodes
    pip install -r requirements.txt
    

    Restart, or search "MF PipoNodes" in ComfyUI Manager. Dependencies are just aiohttp and pyyaml.

    Gotchas

    • 0-based, always. Newcomers index from 1 and silently skip their first line.
    • Out-of-range returns a warning string, not a failure. It won't stop the workflow; it will corrupt whatever it feeds. Validate the index first.
    • Empty lines are real lines. Blank separators consume indices.
    CategoryMF_PipoNodes/Utilities

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    line_indexINT00–1000

    Outputs (1)

    NameTypeDescription
    selected_lineSTRING