improve: add selected_index to ImpactSwitch
fix: invalid type assigning when connect to output of ImpactSwitch other than value
This commit is contained in:
+1
-1
@@ -319,7 +319,7 @@ app.registerExtension({
|
||||
|
||||
if(type == 2) {
|
||||
// connect output
|
||||
if(connected){
|
||||
if(connected && index == 0){
|
||||
if(nodeData.name == 'ImpactSwitch' && app.graph._nodes_by_id[link_info.target_id].type == 'Reroute') {
|
||||
app.graph._nodes_by_id[link_info.target_id].disconnectInput(link_info.target_slot);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import configparser
|
||||
import os
|
||||
|
||||
|
||||
version = "V4.12"
|
||||
version = "V4.12.1"
|
||||
|
||||
dependency_version = 12
|
||||
|
||||
|
||||
@@ -15,14 +15,15 @@ class GeneralSwitch:
|
||||
"hidden": {"unique_id": "UNIQUE_ID", "extra_pnginfo": "EXTRA_PNGINFO"}
|
||||
}
|
||||
|
||||
RETURN_TYPES = (any_typ, "STRING", )
|
||||
RETURN_NAMES = ("selected_value", "selected_label", )
|
||||
RETURN_TYPES = (any_typ, "STRING", "INT")
|
||||
RETURN_NAMES = ("selected_value", "selected_label", "selected_index")
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
def doit(self, *args, **kwargs):
|
||||
input_name = f"input{int(kwargs['select'])}"
|
||||
selected_index = int(kwargs['select'])
|
||||
input_name = f"input{selected_index}"
|
||||
|
||||
selected_label = input_name
|
||||
node_id = kwargs['unique_id']
|
||||
@@ -38,10 +39,10 @@ class GeneralSwitch:
|
||||
break
|
||||
|
||||
if input_name in kwargs:
|
||||
return (kwargs[input_name], selected_label)
|
||||
return (kwargs[input_name], selected_label, selected_index)
|
||||
else:
|
||||
print(f"ImpactSwitch: invalid select index (ignored)")
|
||||
return (None, "")
|
||||
return (None, "", selected_index)
|
||||
|
||||
|
||||
class GeneralInversedSwitch:
|
||||
|
||||
Reference in New Issue
Block a user