diff --git a/comfy_extras/nodes_logic.py b/comfy_extras/nodes_logic.py index ebcb665b3..64b8ab4c1 100644 --- a/comfy_extras/nodes_logic.py +++ b/comfy_extras/nodes_logic.py @@ -58,6 +58,35 @@ class SwitchNode(io.ComfyNode): return io.NodeOutput(on_true) return io.NodeOutput(on_true if switch else on_false) +class SwitchNode2(io.ComfyNode): + @classmethod + def define_schema(cls): + template = io.MatchType.Template("switch") + return io.Schema( + node_id="ComfySwitchNode2", + display_name="Switch2", + category="logic", + inputs=[ + io.Boolean.Input("switch"), + io.MatchType.Input("on_false", template=template, lazy=True), + io.MatchType.Input("on_true", template=template, lazy=True), + ], + outputs=[ + io.MatchType.Output(template=template, display_name="output"), + ], + ) + + @classmethod + def check_lazy_status(cls, switch, on_false=None, on_true=None): + if switch and on_true is None: + return ["on_true"] + if not switch and on_false is None: + return ["on_false"] + + @classmethod + def execute(cls, switch, on_true, on_false) -> io.NodeOutput: + return io.NodeOutput(on_true if switch else on_false) + class CustomComboNode(io.ComfyNode): """ @@ -69,7 +98,7 @@ class CustomComboNode(io.ComfyNode): return io.Schema( node_id="CustomCombo", display_name="Custom Combo", - category="util", + category="utils", is_experimental=True, inputs=[io.Combo.Input("choice", options=[])], outputs=[io.String.Output()] @@ -185,6 +214,7 @@ class LogicExtension(ComfyExtension): async def get_node_list(self) -> list[type[io.ComfyNode]]: return [ SwitchNode, + SwitchNode2, CustomComboNode, DCTestNode, AutogrowNamesTestNode,