2022-12-13 09:20:36 +01:00
|
|
|
function Node_Array(_x, _y, _group = -1) : Node(_x, _y, _group) constructor {
|
2022-01-19 06:11:17 +01:00
|
|
|
name = "Array";
|
2022-01-13 05:24:03 +01:00
|
|
|
previewable = false;
|
|
|
|
|
|
|
|
w = 96;
|
2022-01-19 06:11:17 +01:00
|
|
|
min_h = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-01-19 06:11:17 +01:00
|
|
|
static createNewInput = function() {
|
|
|
|
var index = ds_list_size(inputs);
|
|
|
|
inputs[| index] = nodeValue( index, "Input", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, -1 )
|
|
|
|
.setVisible(true, true);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-12-21 02:30:23 +01:00
|
|
|
if(!LOADING && !APPENDING) createNewInput();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
outputs[| 0] = nodeValue(0, "Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, []);
|
|
|
|
|
2022-01-19 06:11:17 +01:00
|
|
|
static updateValueFrom = function(index) {
|
2022-12-21 02:30:23 +01:00
|
|
|
if(LOADING || APPENDING) return;
|
|
|
|
|
2022-01-19 06:11:17 +01:00
|
|
|
var _l = ds_list_create();
|
|
|
|
for( var i = 0; i < ds_list_size(inputs); i++ ) {
|
2022-12-21 02:30:23 +01:00
|
|
|
if(inputs[| i].value_from)
|
2022-01-19 06:11:17 +01:00
|
|
|
ds_list_add(_l, inputs[| i]);
|
2022-12-21 02:30:23 +01:00
|
|
|
else
|
2022-01-19 06:11:17 +01:00
|
|
|
delete inputs[| i];
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-01-19 06:11:17 +01:00
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
for( var i = 0; i < ds_list_size(_l); i++ )
|
|
|
|
_l[| i].index = i;
|
2022-01-19 06:11:17 +01:00
|
|
|
|
|
|
|
ds_list_destroy(inputs);
|
|
|
|
inputs = _l;
|
|
|
|
|
|
|
|
createNewInput();
|
|
|
|
}
|
|
|
|
|
|
|
|
static update = function() {
|
|
|
|
var res = array_create(ds_list_size(inputs) - 1);
|
|
|
|
|
|
|
|
for( var i = 0; i < ds_list_size(inputs) - 1; i++ ) {
|
|
|
|
res[i] = inputs[| i].getValue();
|
2022-12-27 04:00:50 +01:00
|
|
|
inputs[| i].type = inputs[| i].value_from? inputs[| i].value_from.type : VALUE_TYPE.any;
|
|
|
|
|
|
|
|
if(i == 0)
|
|
|
|
outputs[| 0].type = inputs[| i].value_from? inputs[| i].value_from.type : VALUE_TYPE.any;
|
2022-01-19 06:11:17 +01:00
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
outputs[| 0].setValue(res);
|
|
|
|
}
|
2022-01-19 06:11:17 +01:00
|
|
|
|
|
|
|
static postDeserialize = function() {
|
|
|
|
var _inputs = load_map[? "inputs"];
|
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
for(var i = 0; i < ds_list_size(_inputs); i++)
|
2022-01-19 06:11:17 +01:00
|
|
|
createNewInput();
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|