Created a Switch2 node as a side-by-side test, will likely go with Switch2 as the initial switch node
Some checks failed
Python Linting / Run Ruff (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Build package / Build Test (3.10) (push) Has been cancelled
Build package / Build Test (3.11) (push) Has been cancelled
Build package / Build Test (3.12) (push) Has been cancelled
Build package / Build Test (3.13) (push) Has been cancelled
Build package / Build Test (3.9) (push) Has been cancelled

This commit is contained in:
Jedrzej Kosinski 2025-12-15 23:20:46 -08:00
parent 3c71a0dcdc
commit 85a97cc5c8

View File

@ -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,