2023-03-13 10:45:56 +01:00
|
|
|
function Node_Array_Zip(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|
|
|
name = "Array Zip";
|
2024-03-28 14:18:02 +01:00
|
|
|
setDimension(96, 32 + 24);
|
2023-03-13 10:45:56 +01:00
|
|
|
|
2024-08-20 10:15:53 +02:00
|
|
|
newInput(0, nodeValue("Array", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
|
2023-03-13 10:45:56 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-09-04 03:57:11 +02:00
|
|
|
newOutput(0, nodeValue_Output("Output", self, VALUE_TYPE.integer, 0));
|
2023-03-13 10:45:56 +01:00
|
|
|
|
2024-05-23 10:59:39 +02:00
|
|
|
static createNewInput = function() {
|
2024-08-08 06:57:51 +02:00
|
|
|
var index = array_length(inputs);
|
2023-03-13 10:45:56 +01:00
|
|
|
|
2024-08-20 10:15:53 +02:00
|
|
|
newInput(index, nodeValue("Value", self, CONNECT_TYPE.input, VALUE_TYPE.any, -1 ))
|
2023-03-13 10:45:56 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
return inputs[index];
|
2024-05-23 10:59:39 +02:00
|
|
|
} setDynamicInput(1);
|
2023-03-13 10:45:56 +01:00
|
|
|
|
2023-10-28 04:07:43 +02:00
|
|
|
static step = function() { #region
|
2024-08-08 06:57:51 +02:00
|
|
|
if(inputs[0].value_from == noone) {
|
|
|
|
inputs[0].setType(VALUE_TYPE.any);
|
|
|
|
outputs[0].setType(VALUE_TYPE.any);
|
2023-10-28 04:07:43 +02:00
|
|
|
} else {
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[0].setType(inputs[0].value_from.type);
|
|
|
|
outputs[0].setType(inputs[0].value_from.type);
|
2023-03-13 10:45:56 +01:00
|
|
|
}
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
for( var i = 0; i < array_length(inputs); i += data_length )
|
|
|
|
inputs[i].setType(inputs[i].value_from == noone? VALUE_TYPE.any : inputs[i].value_from.type);
|
2023-10-28 04:07:43 +02:00
|
|
|
} #endregion
|
|
|
|
|
|
|
|
static update = function(frame = CURRENT_FRAME) { #region
|
|
|
|
var _arr = getInputData(0);
|
2023-03-13 10:45:56 +01:00
|
|
|
|
2023-10-28 04:07:43 +02:00
|
|
|
if(!is_array(_arr)) return;
|
2023-03-13 10:45:56 +01:00
|
|
|
var len = 1;
|
|
|
|
var val = [];
|
2024-08-08 06:57:51 +02:00
|
|
|
for( var i = 0; i < array_length(inputs); i += data_length ) {
|
2023-10-02 08:57:44 +02:00
|
|
|
val[i] = getInputData(i);
|
2023-10-28 04:07:43 +02:00
|
|
|
|
2023-03-13 10:45:56 +01:00
|
|
|
if(!is_array(val[i])) {
|
|
|
|
val[i] = [ val[i] ];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
len = max(len, array_length(val[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
var _out = array_create(len);
|
|
|
|
|
|
|
|
for( var i = 0; i < len; i++ ) {
|
2024-08-08 06:57:51 +02:00
|
|
|
for( var j = 0; j < array_length(inputs); j += data_length )
|
2024-03-31 05:36:11 +02:00
|
|
|
_out[i][j] = array_safe_get_fast(val[j], i, 0);
|
2023-03-13 10:45:56 +01:00
|
|
|
}
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0].setValue(_out);
|
2023-10-28 04:07:43 +02:00
|
|
|
} #endregion
|
2023-03-13 10:45:56 +01:00
|
|
|
|
2023-10-28 04:07:43 +02:00
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
2023-03-13 10:45:56 +01:00
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
|
|
draw_sprite_fit(s_node_array_zip, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
2023-10-28 04:07:43 +02:00
|
|
|
} #endregion
|
2023-03-13 10:45:56 +01:00
|
|
|
}
|