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