Pixel-Composer/scripts/node_feedback_output/node_feedback_output.gml

50 lines
1.3 KiB
Text
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_Feedback_Output(_x, _y, _group = noone) : Node_Group_Output(_x, _y, _group) constructor {
2023-02-19 13:49:20 +01:00
name = "Feedback Output";
2022-12-16 09:18:09 +01:00
color = COLORS.node_blend_feedback;
2023-11-29 03:04:28 +01:00
is_group_io = true;
2024-03-28 14:18:02 +01:00
setDimension(96, 32 + 24 * 2);
2022-12-16 09:18:09 +01:00
2024-08-20 10:15:53 +02:00
newInput(1, nodeValue("Feedback loop", self, CONNECT_TYPE.input, VALUE_TYPE.node, -1))
2022-12-16 09:18:09 +01:00
.setVisible(true, true);
cache_value = -1;
2023-10-09 16:07:33 +02:00
static update = function(frame = CURRENT_FRAME) {
2024-08-08 06:57:51 +02:00
if(inputs[0].value_from == noone) return;
2024-01-19 09:33:37 +01:00
if(IS_LAST_FRAME) {
2022-12-27 04:00:50 +01:00
cache_value = noone;
return;
}
var _val_get = getInputData(0);
2024-08-08 06:57:51 +02: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)) {
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(cache_value); i < n; i++ ) {
2022-12-27 04:00:50 +01:00
if(is_surface(cache_value[i]))
surface_free(cache_value[i]);
}
} else if(is_surface(cache_value))
surface_free(cache_value);
if(_arr) {
2023-06-17 18:59:20 +02:00
var amo = is_array(_val_get)? array_length(_val_get) : 0;
2022-12-27 04:00:50 +01:00
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;
}
}
}