2023-02-28 09:43:01 +01:00
|
|
|
function Node_Array_Add(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
2023-01-25 06:49:00 +01:00
|
|
|
name = "Array Add";
|
2024-03-28 14:18:02 +01:00
|
|
|
setDimension(96, 32 + 24);
|
2022-12-16 09:18:09 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(0, nodeValue("Array", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, 0))
|
2022-12-16 09:18:09 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(1, nodeValue_Bool("Spread array", self, false ))
|
2023-04-11 20:29:20 +02:00
|
|
|
.rejectArray();
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0] = nodeValue_Output("Output", self, VALUE_TYPE.integer, 0);
|
2022-12-16 09:18:09 +01:00
|
|
|
|
2024-06-20 03:37:50 +02:00
|
|
|
input_display_list = [ 1, 0 ];
|
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
static createNewInput = function() {
|
2024-08-08 06:57:51 +02:00
|
|
|
var index = array_length(inputs);
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(index, nodeValue("Value", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, -1 ))
|
2023-02-28 09:43:01 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-06-20 03:37:50 +02:00
|
|
|
array_push(input_display_list, index);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
return inputs[index];
|
2024-06-20 03:37:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
setDynamicInput(1);
|
2022-12-16 09:18:09 +01:00
|
|
|
|
2023-10-09 16:07:33 +02:00
|
|
|
static update = function(frame = CURRENT_FRAME) {
|
2023-10-02 08:57:44 +02:00
|
|
|
var _arr = getInputData(0);
|
2022-12-16 09:18:09 +01:00
|
|
|
|
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);
|
2022-12-27 04:00:50 +01:00
|
|
|
return;
|
|
|
|
}
|
2022-12-16 09:18:09 +01:00
|
|
|
|
|
|
|
if(!is_array(_arr)) return;
|
2024-08-08 06:57:51 +02:00
|
|
|
var _type = inputs[0].value_from.type;
|
2023-10-02 08:57:44 +02:00
|
|
|
var spd = getInputData(1);
|
2023-04-11 20:29:20 +02:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[0].setType(_type);
|
|
|
|
outputs[0].setType(_type);
|
2022-12-27 04:00:50 +01:00
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
var _out = array_clone(_arr);
|
2024-08-08 06:57:51 +02:00
|
|
|
for( var i = input_fix_len; i < array_length(inputs); i += data_length ) {
|
2023-10-02 08:57:44 +02:00
|
|
|
var _val = getInputData(i);
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[i].setType(_type);
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2024-06-20 03:37:50 +02:00
|
|
|
if(is_array(_val) && spd) array_append(_out, _val);
|
|
|
|
else array_push(_out, _val);
|
2023-02-28 09:43:01 +01:00
|
|
|
}
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0].setValue(_out);
|
2022-12-16 09:18:09 +01:00
|
|
|
}
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2023-03-13 10:45:56 +01:00
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
|
|
draw_sprite_fit(s_node_array_add, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
|
|
|
}
|
2022-12-16 09:18:09 +01:00
|
|
|
}
|