2023-06-01 10:32:21 +02:00
|
|
|
function Node_Iterate_Each(_x, _y, _group = noone) : Node_Iterator(_x, _y, _group) constructor {
|
2023-11-19 13:33:42 +01:00
|
|
|
name = "Loop Array";
|
2023-02-14 11:40:24 +01:00
|
|
|
|
2024-08-20 10:15:53 +02:00
|
|
|
newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, [] ))
|
2023-02-14 11:40:24 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-09-04 03:57:11 +02:00
|
|
|
newOutput(0, nodeValue_Output("Array", self, VALUE_TYPE.any, [] ));
|
2023-02-14 11:40:24 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
custom_input_index = array_length(inputs);
|
|
|
|
custom_output_index = array_length(inputs);
|
2023-02-14 11:40:24 +01:00
|
|
|
|
2024-05-03 13:40:46 +02:00
|
|
|
if(NODE_NEW_MANUAL) { #region
|
2023-02-14 11:40:24 +01:00
|
|
|
var input = nodeBuild("Node_Iterator_Each_Input", -256, -32, self);
|
|
|
|
var output = nodeBuild("Node_Iterator_Each_Output", 256, -32, self);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
output.inputs[0].setFrom(input.outputs[0]);
|
2023-11-19 13:33:42 +01:00
|
|
|
} #endregion
|
2023-02-14 11:40:24 +01:00
|
|
|
|
2023-11-19 13:33:42 +01:00
|
|
|
static onStep = function() { #region
|
2024-08-08 06:57:51 +02:00
|
|
|
var type = inputs[0].value_from == noone? VALUE_TYPE.any : inputs[0].value_from.type;
|
|
|
|
inputs[0].setType(type);
|
2023-11-19 13:33:42 +01:00
|
|
|
} #endregion
|
2023-02-14 11:40:24 +01:00
|
|
|
|
2023-11-19 13:33:42 +01:00
|
|
|
static doInitLoop = function() { #region
|
2023-12-06 05:09:39 +01:00
|
|
|
var arrIn = getInputData(0);
|
2024-08-08 06:57:51 +02:00
|
|
|
var arrOut = outputs[0].getValue();
|
2023-02-14 11:40:24 +01:00
|
|
|
|
2023-12-06 05:09:39 +01:00
|
|
|
if(array_length(arrOut) != array_length(arrIn))
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0].setValue([]);
|
2023-11-19 13:33:42 +01:00
|
|
|
} #endregion
|
2023-02-14 11:40:24 +01:00
|
|
|
|
2023-11-19 13:33:42 +01:00
|
|
|
static getIterationCount = function() { #region
|
2023-10-02 08:57:44 +02:00
|
|
|
var arrIn = getInputData(0);
|
2023-02-14 11:40:24 +01:00
|
|
|
var maxIter = is_array(arrIn)? array_length(arrIn) : 0;
|
|
|
|
if(!is_real(maxIter)) maxIter = 1;
|
|
|
|
|
2023-04-03 11:55:45 +02:00
|
|
|
return maxIter;
|
2023-11-19 13:33:42 +01:00
|
|
|
} #endregion
|
2023-02-14 11:40:24 +01:00
|
|
|
}
|