Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Has been cancelled
Execution Tests / test (macos-latest) (push) Has been cancelled
Execution Tests / test (ubuntu-latest) (push) Has been cancelled
Execution Tests / test (windows-latest) (push) Has been cancelled
Test server launches without errors / test (push) Has been cancelled
Unit Tests / test (macos-latest) (push) Has been cancelled
Unit Tests / test (ubuntu-latest) (push) Has been cancelled
Unit Tests / test (windows-2022) (push) Has been cancelled
Includes 30 custom nodes committed directly, 7 Civitai-exclusive loras stored via Git LFS, and a setup script that installs all dependencies and downloads HuggingFace-hosted models on vast.ai. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
class AnyType(str):
|
|
"""A special string subclass that equals any other type for ComfyUI type checking."""
|
|
def __ne__(self, __value: object) -> bool:
|
|
return False
|
|
|
|
# Create an instance to use as the any type
|
|
any_type = AnyType("*")
|
|
|
|
class ThreeWaySwitch:
|
|
"""Three-way switch that selects between three inputs based on selection setting."""
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"selection_setting": ("INT", {"default": 1, "min": 1, "max": 3}),
|
|
},
|
|
"optional": {
|
|
"input_1": (any_type,),
|
|
"input_2": (any_type,),
|
|
"input_3": (any_type,),
|
|
}
|
|
}
|
|
|
|
RETURN_TYPES = (any_type,)
|
|
RETURN_NAMES = ("output",)
|
|
FUNCTION = "switch_inputs"
|
|
|
|
CATEGORY = "ControlAltAI Nodes/Logic"
|
|
|
|
@classmethod
|
|
def VALIDATE_INPUTS(cls, **kwargs):
|
|
"""Allow any input types."""
|
|
return True
|
|
|
|
def switch_inputs(self, selection_setting=1, input_1=None, input_2=None, input_3=None):
|
|
"""
|
|
Three-way switch that selects between three inputs based on the selection_setting.
|
|
Compatible with IntegerSettingsAdvanced node:
|
|
- selection_setting = 1: selects input_1
|
|
- selection_setting = 2: selects input_2
|
|
- selection_setting = 3: selects input_3
|
|
"""
|
|
if selection_setting == 2:
|
|
# Second option - select input_2, fallback to input_1, then input_3
|
|
selected_output = input_2 if input_2 is not None else (input_1 if input_1 is not None else input_3)
|
|
elif selection_setting == 3:
|
|
# Third option - select input_3, fallback to input_1, then input_2
|
|
selected_output = input_3 if input_3 is not None else (input_1 if input_1 is not None else input_2)
|
|
else:
|
|
# Default/First option (1) - select input_1, fallback to input_2, then input_3
|
|
selected_output = input_1 if input_1 is not None else (input_2 if input_2 is not None else input_3)
|
|
|
|
return (selected_output,)
|
|
|
|
NODE_CLASS_MAPPINGS = {
|
|
"ThreeWaySwitch": ThreeWaySwitch,
|
|
}
|
|
|
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
|
"ThreeWaySwitch": "Switch (Three Way)",
|
|
} |