How do you call a function with tween_callback and pass arguments?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 8bitsdeep

I’m calling a function after a tween finishes.

This works fine:

tween.tween_callback(apply_damage)

But I need to pass an argument as well, none of these work.

tween.tween_callback(apply_damage(5))
tween.tween_callback(apply_damage, 5)

What is the correct way to do this? Is it possible?

:bust_in_silhouette: Reply From: spaceyjase

Because you’re defining a Callable, it’s necessary to bind to the method as noted here:

Use Callable.bind to bind additional arguments for the call.

e.g.

tween.tween_callback(apply_damage.bind(5))

Thank you! Don’t know how I missed that line.

8bitsdeep | 2023-03-13 17:02