How do I use a built string to reference a variable which contains a GUI node? I’m sorry if this a basic Lua thing, but I haven’t been able to find a solution elsewhere.
I have 5 numbered panels on the GUI of a ‘Save/Load’ screen. Each panel has 3 buttons numbered accordingly and I’m wanting to iterate through them for each panel to check whether each button has been clicked and run the relevant code. The buttons nodes and state are all stored in a table.
The below code (edited for brevity) doesn’t work and the error spat out is pretty obvious:
… bad argument #1 to ‘pick_node’ (NodeProxy expected, got string)
if action_id == hash("touch") and action.pressed then
for panel = 1,5,1 do
local new_button = "buttons.new_".. panel .. ".node"
if gui.pick_node(new_button, action.x, action.y) then
msg.post("main:/scenes#loader", "load_scene", { scene = "new_game" })
end
end
end