Skip to content

Commit 85a97cc

Browse files
committed
Created a Switch2 node as a side-by-side test, will likely go with Switch2 as the initial switch node
1 parent 3c71a0d commit 85a97cc

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

comfy_extras/nodes_logic.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,35 @@ def execute(cls, switch, on_true=MISSING, on_false=MISSING) -> io.NodeOutput:
5858
return io.NodeOutput(on_true)
5959
return io.NodeOutput(on_true if switch else on_false)
6060

61+
class SwitchNode2(io.ComfyNode):
62+
@classmethod
63+
def define_schema(cls):
64+
template = io.MatchType.Template("switch")
65+
return io.Schema(
66+
node_id="ComfySwitchNode2",
67+
display_name="Switch2",
68+
category="logic",
69+
inputs=[
70+
io.Boolean.Input("switch"),
71+
io.MatchType.Input("on_false", template=template, lazy=True),
72+
io.MatchType.Input("on_true", template=template, lazy=True),
73+
],
74+
outputs=[
75+
io.MatchType.Output(template=template, display_name="output"),
76+
],
77+
)
78+
79+
@classmethod
80+
def check_lazy_status(cls, switch, on_false=None, on_true=None):
81+
if switch and on_true is None:
82+
return ["on_true"]
83+
if not switch and on_false is None:
84+
return ["on_false"]
85+
86+
@classmethod
87+
def execute(cls, switch, on_true, on_false) -> io.NodeOutput:
88+
return io.NodeOutput(on_true if switch else on_false)
89+
6190

6291
class CustomComboNode(io.ComfyNode):
6392
"""
@@ -69,7 +98,7 @@ def define_schema(cls):
6998
return io.Schema(
7099
node_id="CustomCombo",
71100
display_name="Custom Combo",
72-
category="util",
101+
category="utils",
73102
is_experimental=True,
74103
inputs=[io.Combo.Input("choice", options=[])],
75104
outputs=[io.String.Output()]
@@ -185,6 +214,7 @@ class LogicExtension(ComfyExtension):
185214
async def get_node_list(self) -> list[type[io.ComfyNode]]:
186215
return [
187216
SwitchNode,
217+
SwitchNode2,
188218
CustomComboNode,
189219
DCTestNode,
190220
AutogrowNamesTestNode,

0 commit comments

Comments
 (0)