2023-03-28 06:58:28 +02:00
|
|
|
function Node_Trigger_Bool(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|
|
|
name = "Boolean Trigger";
|
|
|
|
update_on_frame = true;
|
2024-03-28 14:18:02 +01:00
|
|
|
setDimension(96, 32 + 24 * 1);
|
2023-03-28 06:58:28 +02:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(0, nodeValue_Bool("Boolean", self, false));
|
2023-03-28 06:58:28 +02:00
|
|
|
|
2024-08-20 10:15:53 +02:00
|
|
|
newInput(1, nodeValue_Enum_Scroll("Trigger condition", self, 0, [ new scrollItem("True frame", s_node_trigger_cond, 0),
|
|
|
|
new scrollItem("False to True", s_node_trigger_cond, 1),
|
|
|
|
new scrollItem("True to False", s_node_trigger_cond, 2),
|
|
|
|
new scrollItem("Value changed", s_node_trigger_cond, 3), ]));
|
2023-03-28 06:58:28 +02:00
|
|
|
|
2024-09-04 03:57:11 +02:00
|
|
|
newOutput(0, nodeValue_Output("Trigger", self, VALUE_TYPE.trigger, false));
|
2023-03-28 06:58:28 +02:00
|
|
|
|
|
|
|
prevVal = false;
|
|
|
|
preview = false;
|
|
|
|
|
2023-06-13 14:42:06 +02:00
|
|
|
doTrigger = 0;
|
|
|
|
|
2023-09-26 14:35:25 +02:00
|
|
|
static update = function() {
|
2024-06-20 13:22:21 +02:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var val = getInputData(0);
|
|
|
|
var con = getInputData(1);
|
2023-03-28 06:58:28 +02:00
|
|
|
|
|
|
|
switch(con) {
|
2023-06-13 14:42:06 +02:00
|
|
|
case 0 : doTrigger = val; break;
|
|
|
|
case 1 : doTrigger = !prevVal && val; break;
|
2023-08-19 12:42:50 +02:00
|
|
|
case 2 : doTrigger = prevVal && !val; break;
|
2023-06-13 14:42:06 +02:00
|
|
|
case 3 : doTrigger = prevVal != val; break;
|
2023-03-28 06:58:28 +02:00
|
|
|
}
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0].setValue(doTrigger);
|
2024-06-20 13:22:21 +02:00
|
|
|
|
2023-06-13 14:42:06 +02:00
|
|
|
preview = doTrigger;
|
2023-03-28 06:58:28 +02:00
|
|
|
prevVal = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
2023-11-23 08:28:04 +01:00
|
|
|
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
|
2023-03-28 06:58:28 +02:00
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
2024-03-31 05:36:11 +02:00
|
|
|
draw_sprite_fit(THEME.node_trigger_icon, preview, bbox.xc, bbox.yc, bbox.w, bbox.h, preview? COLORS._main_accent : COLORS._main_icon);
|
2023-03-28 06:58:28 +02:00
|
|
|
}
|
|
|
|
}
|