@@ -10,23 +10,25 @@ app.registerExtension({
1010 switch ( nodeData . name ) {
1111 case "ConditioningMultiCombine" :
1212 nodeType . prototype . onNodeCreated = function ( ) {
13- this . cond_type = "CONDITIONING"
13+ this . _type = "CONDITIONING"
1414 this . inputs_offset = nodeData . name . includes ( "selective" ) ?1 :0
1515 this . addWidget ( "button" , "Update inputs" , null , ( ) => {
1616 if ( ! this . inputs ) {
1717 this . inputs = [ ] ;
1818 }
1919 const target_number_of_inputs = this . widgets . find ( w => w . name === "inputcount" ) [ "value" ] ;
20- const num_inputs = this . inputs . filter ( input => input . type === this . cond_type ) . length
20+ const num_inputs = this . inputs . filter ( input => input . type === this . _type ) . length
2121 if ( target_number_of_inputs === num_inputs ) return ; // already set, do nothing
2222
2323 if ( target_number_of_inputs < num_inputs ) {
24- for ( let i = num_inputs ; i >= this . inputs_offset + target_number_of_inputs ; i -- )
25- this . removeInput ( i )
24+ const inputs_to_remove = num_inputs - target_number_of_inputs ;
25+ for ( let i = 0 ; i < inputs_to_remove ; i ++ ) {
26+ this . removeInput ( this . inputs . length - 1 ) ;
27+ }
2628 }
2729 else {
28- for ( let i = num_inputs + 1 - this . inputs_offset ; i <= target_number_of_inputs ; ++ i )
29- this . addInput ( `conditioning_${ i } ` , this . cond_type )
30+ for ( let i = num_inputs + 1 ; i <= target_number_of_inputs ; ++ i )
31+ this . addInput ( `conditioning_${ i } ` , this . _type )
3032 }
3133 } ) ;
3234 }
@@ -43,9 +45,7 @@ app.registerExtension({
4345 this . inputs = [ ] ;
4446 }
4547 const target_number_of_inputs = this . widgets . find ( w => w . name === "inputcount" ) [ "value" ] ;
46- console . log ( "target_number_of_inputs" , target_number_of_inputs )
4748 const num_inputs = this . inputs . filter ( input => input . type === this . _type ) . length
48- console . log ( "num_inputs" , num_inputs )
4949 if ( target_number_of_inputs === num_inputs ) return ; // already set, do nothing
5050
5151 if ( target_number_of_inputs < num_inputs ) {
0 commit comments