From b37122a9fd079b2854fa92565582a195d6b03c92 Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Wed, 20 Aug 2025 21:06:39 +0300 Subject: [PATCH] Add LazySwitchKJ --- __init__.py | 1 + nodes/nodes.py | 32 +++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index 0c9c7f1..d3d1325 100644 --- a/__init__.py +++ b/__init__.py @@ -136,6 +136,7 @@ NODE_CONFIG = { "SetShakkerLabsUnionControlNetType": {"class": SetShakkerLabsUnionControlNetType, "name": "Set Shakker Labs Union ControlNet Type"}, "StyleModelApplyAdvanced": {"class": StyleModelApplyAdvanced, "name": "Style Model Apply Advanced"}, "DiffusionModelSelector": {"class": DiffusionModelSelector, "name": "Diffusion Model Selector"}, + "LazySwitchKJ": {"class": LazySwitchKJ, "name": "Lazy Switch KJ"}, #audioscheduler stuff "NormalizedAmplitudeToMask": {"class": NormalizedAmplitudeToMask}, "NormalizedAmplitudeToFloatList": {"class": NormalizedAmplitudeToFloatList}, diff --git a/nodes/nodes.py b/nodes/nodes.py index dbbd185..afc793f 100644 --- a/nodes/nodes.py +++ b/nodes/nodes.py @@ -2592,4 +2592,34 @@ class HunyuanVideoEncodeKeyframesToCond: out.append(c) if len(out) == 1: out.append(out[0]) - return (model_clone, out[0], out[1], out_latent) \ No newline at end of file + return (model_clone, out[0], out[1], out_latent) + + +class LazySwitchKJ: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "switch": ("BOOLEAN",), + "on_false": (IO.ANY, {"lazy": True}), + "on_true": (IO.ANY, {"lazy": True}), + }, + } + + RETURN_TYPES = (IO.ANY,) + FUNCTION = "switch" + CATEGORY = "KJNodes/misc" + DESCRIPTION = "Controls flow of execution based on a boolean switch." + + def check_lazy_status(self, 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"] + + def switch(self, switch, on_false = None, on_true=None): + value = on_true if switch else on_false + return (value,) \ No newline at end of file