Pixel-Composer/scripts/node_feedback_output/node_feedback_output.gml

52 lines
1.3 KiB
Plaintext
Raw Normal View History

2022-12-16 09:18:09 +01:00
function Node_Feedback_Output(_x, _y, _group = -1) : Node_Group_Output(_x, _y, _group) constructor {
name = "Output";
color = COLORS.node_blend_feedback;
w = 96;
h = 32 + 24 * 2;
min_h = h;
2023-02-14 05:32:32 +01:00
inputs[| 2] = nodeValue("Feedback loop", self, JUNCTION_CONNECT.input, VALUE_TYPE.node, -1)
2022-12-16 09:18:09 +01:00
.setVisible(true, true);
cache_value = -1;
2023-02-14 05:32:32 +01:00
static update = function(frame = ANIMATOR.current_frame) {
2022-12-27 04:00:50 +01:00
if(inputs[| 0].value_from == noone) return;
if(ANIMATOR.current_frame == ANIMATOR.frames_total - 1) {
cache_value = noone;
return;
}
2022-12-16 09:18:09 +01:00
var _val_get = inputs[| 0].getValue();
2022-12-27 04:00:50 +01:00
var _arr = inputs[| 0].value_from.isArray();
var is_surf = inputs[| 0].type == VALUE_TYPE.surface;
2022-12-16 09:18:09 +01:00
2022-12-27 04:00:50 +01:00
if(is_array(cache_value)) {
for( var i = 0; i < array_length(cache_value); i++ ) {
if(is_surface(cache_value[i]))
surface_free(cache_value[i]);
}
} else if(is_surface(cache_value))
surface_free(cache_value);
if(_arr) {
var amo = array_length(_val_get);
cache_value = array_create(amo);
if(is_surf) {
for( var i = 0; i < amo; i++ ) {
if(is_surface(_val_get[i]))
cache_value[i] = surface_clone(_val_get[i]);
}
} else
cache_value = _val_get;
} else {
if(is_surf) {
if(is_surface(_val_get))
2022-12-16 09:18:09 +01:00
cache_value = surface_clone(_val_get);
2022-12-27 04:00:50 +01:00
} else
2022-12-16 09:18:09 +01:00
cache_value = _val_get;
}
}
}