Files
younger15 25399acf49 first upload
text switch(with add)
clip switch
condition switch
image switch
model switch
2026-04-22 22:56:25 +08:00

29 lines
1.0 KiB
Python

class Iter_FloatSwitch:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"output_index": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
"input_count": ("INT", {"default": 2, "min": 1, "max": 128, "step": 1}),
"use_last_input": ("BOOLEAN", {"default": True}),
},
}
RETURN_TYPES = ("FLOAT",)
FUNCTION = "switch_float"
CATEGORY = "CustomNodes/Iterators"
def switch_float(self, output_index, input_count, use_last_input, **kwargs):
# 1. 計算目標索引
target_idx = output_index % input_count
# 2. 搜尋有效浮點數
res_float = None
for i in range(target_idx, -1, -1):
val = kwargs.get(f"float_{i}")
# 注意:在 Python 中 0.0 是 False,所以要檢查是否為 None
if val is not None or not use_last_input:
res_float = val
break
return (float(res_float),)