2023-10-27 15:42:17 +02:00
|
|
|
function Node_Struct_Set(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|
|
|
name = "Struct Set";
|
|
|
|
|
2024-05-02 11:05:02 +02:00
|
|
|
setDimension(96, 48);
|
2023-10-27 15:42:17 +02:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(0, nodeValue_Struct("Struct", self, {}))
|
2023-10-27 15:42:17 +02:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(1, nodeValue_Text("Key", self, ""));
|
2023-10-27 15:42:17 +02:00
|
|
|
|
2024-10-06 11:23:58 +02:00
|
|
|
newInput(2, nodeValue("Value", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
|
|
|
|
.setVisible(true, true);
|
2023-10-27 15:42:17 +02:00
|
|
|
|
2024-09-04 03:57:11 +02:00
|
|
|
newOutput(0, nodeValue_Output("Struct", self, VALUE_TYPE.struct, {}));
|
2023-10-27 15:42:17 +02:00
|
|
|
|
|
|
|
static update = function() {
|
|
|
|
var str = getInputData(0);
|
|
|
|
var key = getInputData(1);
|
|
|
|
var val = getInputData(2);
|
|
|
|
|
2024-10-06 11:23:58 +02:00
|
|
|
var _str = variable_clone(str, 1);
|
|
|
|
if(key != "") _str[$ key] = val;
|
2023-10-27 15:42:17 +02:00
|
|
|
|
2024-10-06 11:23:58 +02:00
|
|
|
inputs[2].setType(inputs[2].value_from == noone? VALUE_TYPE.any : inputs[2].value_from.type);
|
|
|
|
outputs[0].setValue(_str)
|
2023-10-27 15:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
|
|
var str = getInputData(1);
|
|
|
|
|
2023-11-23 08:28:04 +01:00
|
|
|
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
|
2023-10-27 15:42:17 +02:00
|
|
|
var ss = string_scale(str, bbox.w, bbox.h);
|
|
|
|
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
|
|
|
|
}
|
|
|
|
}
|