Pixel-Composer/scripts/node_iterate_each/node_iterate_each.gml

39 lines
1.2 KiB
Text
Raw Normal View History

2023-06-01 10:32:21 +02:00
function Node_Iterate_Each(_x, _y, _group = noone) : Node_Iterator(_x, _y, _group) constructor {
name = "Loop Array";
2023-02-14 17:40:24 +07:00
inputs[| 0] = nodeValue("Array", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, [] )
.setVisible(true, true);
outputs[| 0] = nodeValue("Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, [] );
custom_input_index = ds_list_size(inputs);
2023-02-14 17:40:24 +07:00
custom_output_index = ds_list_size(inputs);
if(!LOADING && !APPENDING && !CLONING) { #region
2023-02-14 17:40:24 +07:00
var input = nodeBuild("Node_Iterator_Each_Input", -256, -32, self);
var output = nodeBuild("Node_Iterator_Each_Output", 256, -32, self);
output.inputs[| 0].setFrom(input.outputs[| 0]);
} #endregion
2023-02-14 17:40:24 +07:00
static onStep = function() { #region
2023-10-27 18:55:31 +07:00
var type = inputs[| 0].isLeaf()? VALUE_TYPE.any : inputs[| 0].value_from.type;
2023-10-07 21:23:40 +07:00
inputs[| 0].setType(type);
} #endregion
2023-02-14 17:40:24 +07:00
static doInitLoop = function() { #region
2023-12-06 11:09:39 +07:00
var arrIn = getInputData(0);
2023-02-19 19:49:20 +07:00
var arrOut = outputs[| 0].getValue();
2023-02-14 17:40:24 +07:00
2023-12-06 11:09:39 +07:00
if(array_length(arrOut) != array_length(arrIn))
outputs[| 0].setValue([]);
} #endregion
2023-02-14 17:40:24 +07:00
static getIterationCount = function() { #region
var arrIn = getInputData(0);
2023-02-14 17:40:24 +07:00
var maxIter = is_array(arrIn)? array_length(arrIn) : 0;
if(!is_real(maxIter)) maxIter = 1;
return maxIter;
} #endregion
2023-02-14 17:40:24 +07:00
}