mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 14:36:13 +01:00
61 lines
No EOL
1.3 KiB
Text
61 lines
No EOL
1.3 KiB
Text
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 {
|
|
name = "Array";
|
|
previewable = false;
|
|
|
|
w = 96;
|
|
min_h = 0;
|
|
|
|
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);
|
|
}
|
|
createNewInput();
|
|
|
|
outputs[| 0] = nodeValue(0, "Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, []);
|
|
|
|
static updateValueFrom = function(index) {
|
|
var _l = ds_list_create();
|
|
for( var i = 0; i < ds_list_size(inputs); i++ ) {
|
|
if(inputs[| i].value_from) {
|
|
ds_list_add(_l, inputs[| i]);
|
|
} else {
|
|
delete inputs[| i];
|
|
}
|
|
}
|
|
|
|
for( var i = 0; i < ds_list_size(_l); i++ ) {
|
|
_l[| i].index = i;
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
outputs[| 0].setValue(res);
|
|
}
|
|
doUpdate();
|
|
|
|
static postDeserialize = function() {
|
|
var _inputs = load_map[? "inputs"];
|
|
|
|
for(var i = 0; i < ds_list_size(_inputs); i++) {
|
|
createNewInput();
|
|
}
|
|
}
|
|
} |