Lua Script Node
Dedicated Lua scripted node that automatically executes lifecycle callbacks (ready, update, render).
Type: ScriptNode · Category: Core & 2D · Also found as: script
A node whose job is to run a script - a manager, a spawner, game rules. Any node can run a script (Inspector > Script); a Script node is simply an empty node made for it.
-- scripts/game_rules.lua on a Script node named "Rules"local Rules = {}
function Rules:ready() self.score = 0end
function Rules:add_points(n) self.score = self.score + nend
return RulesOther scripts reach it with Scene.find_node("Rules"):get_script():add_points(10).
For a script that should outlive scene changes, make it a global script
instead (see the scripting guide).
Properties
Section titled “Properties”No reflected properties of its own: its settings are described above.
Plus the common properties every node has.
In a scene file
Section titled “In a scene file”{ "type": "ScriptNode", "name": "LuaScriptNode", "position": [ 0, 0 ]}