Animation [complete_function] starting early? (SOLVED)

I have something like:
if message_id == hash("fade_out") then gui.animate(self.transition_node, gui.PROP_SCALE, 1.5, gui.EASING_INOUTQUAD, 1, 0.0, on_animation_done(message.scene)) end
Which in turn should then call a function I have created that changes the scene when the animation finishes, however the scene changes immediately after the message is passed, but if I instead use on_animation_doneit kinda works, but I can’t pass any parameters to it which in turn doesn’t change the scene correctly.

Why is this happening? I’m getting that the [complete_function] works only on non-parameter functions, but why is that? or am I missing something, could it be possible to use a normal function after the animation finishes or would I need to use a completely different approach?

because gui.animate() expects you to pass a function, NOT the function execution. When you add brackets () you execute function, without them - it’s just a function value.

To pass parameters you just need to wrap your function call in an anonymous function.

gui.animate(self.transition_node, gui.PROP_SCALE, 1.5, gui.EASING_INOUTQUAD, 1, 0.0, function() on_animation_done(message.scene) end)
6 Likes

To pass parameters you just need to wrap your function call in an anonymous function.

Ah, so that’s how it’s done! Good to know.

2 Likes