diff --git a/README.md b/README.md index 8cc3117..27e7e57 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 🔗 Comfyui : Bjornulf_custom_nodes v0.9 🔗 +# 🔗 Comfyui : Bjornulf_custom_nodes v0.10 🔗 # Dependencies @@ -17,7 +17,7 @@ - **v0.8**: Combine images : add an option to put image top, bottom or center. - **v0.8**: Combine texts : add option for slashes / - **v0.8**: Add basic node to transform greenscreen in to transparency. -- **v0.9**: Add a new node : Return one random line from input. +- **v0.10**: Add a new node : Loop (All Lines from input) - Iterate over all lines from an input text. # 📝 Nodes descriptions @@ -187,3 +187,8 @@ Need clean greenscreen ofc. (Can adjust threshold but very basic node.) **Description:** Take a random line from an input text. (When using multiple "Write Text" nodes is annoying for example, you can use that and just copy/paste a list from outside.) +## 27 - ♻ Loop (All Lines from input) +![Combine Images](screenshots/loop_all_lines.png) + +**Description:** +Iterate over all lines from an input text. (Good for testing multiple lines of text.) diff --git a/__init__.py b/__init__.py index 62a5d9b..d1c8c07 100644 --- a/__init__.py +++ b/__init__.py @@ -31,6 +31,7 @@ from .combine_background_overlay import CombineBackgroundOverlay from .save_bjornulf_lobechat import SaveBjornulfLobeChat from .green_to_transparency import GreenScreenToTransparency from .random_line_from_input import RandomLineFromInput +from .loop_lines import LoopAllLines # from .check_black_image import CheckBlackImage # from .clear_vram import ClearVRAM @@ -39,6 +40,7 @@ from .random_line_from_input import RandomLineFromInput NODE_CLASS_MAPPINGS = { # "Bjornulf_CustomStringType": CustomStringType, "Bjornulf_ollamaLoader": ollamaLoader, + "Bjornulf_LoopAllLines": LoopAllLines, "Bjornulf_GreenScreenToTransparency": GreenScreenToTransparency, "Bjornulf_RandomLineFromInput": RandomLineFromInput, # "Bjornulf_CheckBlackImage": CheckBlackImage, @@ -111,6 +113,7 @@ NODE_DISPLAY_NAME_MAPPINGS = { "Bjornulf_LoopFloat": "♻ Loop (Float)", "Bjornulf_LoopInteger": "♻ Loop (Integer)", "Bjornulf_LoopBasicBatch": "♻ Loop", + "Bjornulf_LoopAllLines": "♻ Loop (All Lines from input)", "Bjornulf_LoopSamplers": "♻ Loop (All Samplers)", "Bjornulf_LoopSchedulers": "♻ Loop (All Schedulers)", "Bjornulf_LoopCombosSamplersSchedulers": "♻ Loop (My combos Sampler⚔Scheduler)", diff --git a/loop_lines.py b/loop_lines.py new file mode 100644 index 0000000..32f659d --- /dev/null +++ b/loop_lines.py @@ -0,0 +1,26 @@ +class LoopAllLines: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "text": ("STRING", {"forceInput": True}), + } + } + + RETURN_TYPES = ("STRING",) + FUNCTION = "all_lines" + OUTPUT_IS_LIST = (True,) + CATEGORY = "Bjornulf" + + def all_lines(self, text): + # Split the input text into lines + lines = text.split('\n') + + # Remove empty lines and strip whitespace + lines = [line.strip() for line in lines if line.strip()] + + if not lines: + return ([],) + + # Return all non-empty lines + return (lines,) \ No newline at end of file diff --git a/screenshots/loop_all_lines.png b/screenshots/loop_all_lines.png new file mode 100644 index 0000000..2400cd1 Binary files /dev/null and b/screenshots/loop_all_lines.png differ