Skip to content

📜 CR Text Cycler

Documentation

  • Class name: CR Text Cycler
  • Category: 🧩 Comfyroll Studio/✨ Essential/📜 List
  • Output node: False

The CR Text Cycler node is designed to repeat and loop through given text lines, creating a list of text items based on specified repetition and loop counts. It facilitates the generation of repetitive text sequences for various applications, such as animations or list manipulations.

Input types

Required

  • text
    • The 'text' parameter takes a multiline string input, which is split into lines to be cycled through. It serves as the base content for repetition and looping, forming the core of the text sequences generated by the node.
    • Comfy dtype: STRING
    • Python dtype: str
  • repeats
    • The 'repeats' parameter specifies how many times each line of text is to be repeated within a single loop. It controls the density of repetition for each text item, affecting the overall length and composition of the output list.
    • Comfy dtype: INT
    • Python dtype: int
  • loops
    • The 'loops' parameter determines the number of times the entire set of text lines (after applying the 'repeats' parameter) is looped over. It influences the final size of the output list by repeating the sequence of text items multiple times.
    • Comfy dtype: INT
    • Python dtype: int

Output types

  • STRING
    • Comfy dtype: *
    • This output is a list of text items generated by cycling through the input text lines according to the specified 'repeats' and 'loops' parameters. It represents the repeated and looped text sequence.
    • Python dtype: List[str]
  • show_text
    • Comfy dtype: STRING
    • A URL providing additional help and documentation for using the CR Text Cycler node.
    • Python dtype: str

Usage tips

  • Infra type: CPU
  • Common nodes: unknown

Source code

class CR_TextCycler:

    @classmethod
    def INPUT_TYPES(s):
        return {"required": {
            "text": ("STRING", {"multiline": True, "default": ""}),
            "repeats": ("INT", {"default": 1, "min": 1, "max": 99999}),
            "loops": ("INT", {"default": 1, "min": 1, "max": 99999}),
            }
        }

    RETURN_TYPES = (any_type, "STRING", )
    RETURN_NAMES = ("STRING", "show_text", )
    OUTPUT_IS_LIST = (True, False)
    FUNCTION = "cycle"
    CATEGORY = icons.get("Comfyroll/List")    

    def cycle(self, text, repeats, loops=1):

        show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/List-Nodes#cr-text-cycler"

        lines = text.split('\n')
        list_out = []

        for i in range(loops):
            for text_item in lines:
                for _ in range(repeats):
                    list_out.append(text_item)

        return (list_out, show_help,)