Pixel-Composer/scripts/node_lua_global/node_lua_global.gml
Tanasart a581d4fbe1 1.17.0.2
- [Loop array] Output now duplicate data instead of referencing it.
- [Splice Spritesheet] Fix output empty when either width or height is set to 1.
- [Splice Spritesheet] Fix vertical orientation output error.
- [Atlas set] Add an option to recalculate position after applying new rotation.
2024-05-07 11:53:51 +07:00

42 lines
1.3 KiB
Plaintext

function Node_Lua_Global(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Lua Global";
preview_channel = 1;
inputs[| 0] = nodeValue("Lua code", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "", o_dialog_lua_reference)
.setDisplay(VALUE_DISPLAY.codeLUA);
inputs[| 1] = nodeValue("Run order", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "On start", "Every frame" ]);
inputs[| 2] = nodeValue("Execution thread", self, JUNCTION_CONNECT.input, VALUE_TYPE.node, noone)
.setVisible(false, true);
outputs[| 0] = nodeValue("Execution thread", self, JUNCTION_CONNECT.output, VALUE_TYPE.node, noone );
input_display_list = [
["Main", false], 2, 1, 0,
];
lua_state = lua_create();
is_beginning = false;
static getState = function() { #region
if(inputs[| 2].value_from == noone) return lua_state;
return inputs[| 2].value_from.node.getState();
} #endregion
static update = function(frame = CURRENT_FRAME) { #region
var _code = getInputData(0);
var _type = getInputData(1);
update_on_frame = _type;
lua_projectData(getState());
try { lua_add_code(getState(), _code); }
catch(e) { noti_warning(exception_print(e),, self); }
} #endregion
static onDestroy = function() { #region
lua_state_destroy(lua_state);
} #endregion
}