I’m having a problem animating a gui node for an in-game menu, specifically with the ‘complete_function’ I’ve defined, which doesn’t seem to recognise the node sent in its parameter.
The animation when opening it works fine, but the closing part throws up an error.
My code is as follows:
function init(self)
msg.post(".", "acquire_input_focus")
local menu_panel = gui.get_node("menu_panel")
gui.set_scale(menu_panel, vmath.vector3(0, 0, 0))
gui.set_enabled(menu_panel, false)
end
local function gui_disable(self, gui_node)
gui.set_scale(gui_node, vmath.vector3(0, 0, 0))
gui.set_enabled(gui_node, false)
end
function on_input(self, action_id, action)
local menu_panel = gui.get_node("menu_panel")
local menu_enabled = gui.is_enabled(menu_panel)
if menu_enabled == false then
if action_id == hash("Menu") and action.pressed then
gui.set_enabled(menu_panel, true)
gui.animate(menu_panel, "scale", 1.0, gui.EASING_OUTBACK, 0.25, 0, nil, gui.PLAYBACK_ONCE_FORWARD)
end
elseif menu_enabled == true then
if action_id == hash("Menu") and action.pressed then
gui.animate(menu_panel, "scale", 0, gui.EASING_INBACK, 0.25, 0, gui_disable(menu_panel), gui.PLAYBACK_ONCE_FORWARD)
end
end
end
The error message I’m getting is…
ERROR:SCRIPT: main/gui/game_menu.gui_script:10: bad argument #1 to 'set_scale' (NodeProxy expected, got nil)
stack traceback:
[C]:-1: in function set_scale
main/gui/game_menu.gui_script:10: in function gui_disable
main/gui/game_menu.gui_script:29: in function <main/gui/game_menu.gui_script:14>
Thanks in advance for any responses!