2022-01-13 05:24:03 +01:00
|
|
|
function Node_create_Array(_x, _y) {
|
|
|
|
var node = new Node_Array(_x, _y);
|
|
|
|
ds_list_add(PANEL_GRAPH.nodes_list, node);
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
function Node_Array(_x, _y) : Node(_x, _y) 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-01-19 06:11:17 +01:00
|
|
|
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) {
|
|
|
|
var _l = ds_list_create();
|
|
|
|
for( var i = 0; i < ds_list_size(inputs); i++ ) {
|
2022-01-13 05:24:03 +01:00
|
|
|
if(inputs[| i].value_from) {
|
2022-01-19 06:11:17 +01:00
|
|
|
ds_list_add(_l, inputs[| i]);
|
|
|
|
} else {
|
|
|
|
delete inputs[| i];
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
2022-01-19 06:11:17 +01:00
|
|
|
|
|
|
|
for( var i = 0; i < ds_list_size(_l); i++ ) {
|
|
|
|
_l[| i].index = i;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
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-01-13 05:24:03 +01:00
|
|
|
outputs[| 0].setValue(res);
|
|
|
|
}
|
|
|
|
doUpdate();
|
2022-01-19 06:11:17 +01:00
|
|
|
|
|
|
|
static postDeserialize = function() {
|
|
|
|
var _inputs = load_map[? "inputs"];
|
|
|
|
|
|
|
|
for(var i = 0; i < ds_list_size(_inputs); i++) {
|
|
|
|
createNewInput();
|
|
|
|
}
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|