Added switch text node

This commit is contained in:
exectails
2024-11-26 12:40:15 +01:00
parent 316fa18e01
commit bd47912c59
2 changed files with 27 additions and 0 deletions
+1
View File
@@ -21,6 +21,7 @@ NODE_CLASS_MAPPINGS = {
NODE_DISPLAY_NAME_MAPPINGS = {
"ETSplitTextNode": "Split Text",
"ETJoinTextNode": "Join Text",
"ETSwitchTextNode": "Switch Text",
"ETATOI": "ATOI",
"ETITOA": "ITOA",
+26
View File
@@ -54,3 +54,29 @@ class ETJoinTextNode:
result = prefix + join_with.join(text) + suffix
return (result,)
class ETSwitchTextNode:
"""
A node that outputs one of two options depending on a boolean switch.
"""
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"option1": ("STRING", {"default": "", "multiline": False, "tooltip": "The option that will returned if the switch is off/false."}),
"option2": ("STRING", {"default": "", "multiline": False, "tooltip": "The option that will returned if the switch is on/true."}),
"switch": ("BOOLEAN", {"default": False, "label_off": "option1", "label_on": "option2", "tooltip": "The switch that determines which option to return. Option 1 if off, option 2 if on."}),
},
}
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("text",)
CATEGORY = "exectails/Strings"
FUNCTION = "process"
def process(self, option1: str = "", option2: str = "", switch: bool = False) -> tuple:
result = option1 if not switch else option2
return (result,)