Files
Bjornulf_custom_nodes/loop_texts.py
2024-07-06 12:05:16 +02:00

23 lines
778 B
Python

class LoopTexts:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"number_of_inputs": ("INT", {"default": 2, "min": 2, "max": 10, "step": 1}),
"text_1": ("STRING", {"forceInput": "True"}),
"text_2": ("STRING", {"forceInput": "True"}),
},
"hidden": {
**{f"text_{i}": ("STRING", {"forceInput": "True"}) for i in range(3, 11)}
}
}
RETURN_TYPES = ("STRING",)
FUNCTION = "loop_texts"
OUTPUT_IS_LIST = (True,)
CATEGORY = "Bjornulf"
def loop_texts(self, number_of_inputs, **kwargs):
text_list = [kwargs[f"text_{i}"] for i in range(1, number_of_inputs + 1) if f"text_{i}" in kwargs]
return (text_list,)