How to use tween.set_trans and tween.set_ease with outside variables

Godot Version

4.6.2.stable.official

Question

Context: I have made a function in an autoloaded script (cinematic_controller), in which i tween the position of my camera to different locations. By running this function with arguments (tween-end-position, tween-duration, transition & ease type) i can move the camera in a bunch of different ways.

What i’m struggling with is how to use the two latter arguments (transition and ease) in the tween itself.

Here is the function:

- cinematic_controller.gd (autoload)

func move_cam(end_pos : Vector2, duration, transition, easing)
    var tween = create_tween()
	tween.tween_property(self, "cam_pos", end_pos, duration)
	tween.set_trans(transition)
	tween.set_ease(easing)

Here’s how i call it:

- mc.gd

cinematic_controller.move_camera(Vector2(0, 0), Vector2(200, 100), 5, "tween.TRANS_SINE", "tween.EASE_IN_OUT")

This gives the error:

Invalid type in function ‘set_trans’ in base ‘Tween’. Cannot convert argument 1 from String to int.

As a beginner to game development and a newcomer to gdscript this is confusing me. Converting the strings to int manually wouldn’t do me any good, so i honestly have no idea what to do here. The docs also didn’t mention (not that i found) anything about using arguments like this when tweening.

Thanks for any help and lmk if you need more details

in the mc.gd, your passing the arguments as String, rather as a TransitionType and EaseType.

Try changing the String arguments to Tween.TRANS_SINE and Tween.EASE_IN_OUT, with no “".

also in the func move_cam, try adding something like:

transition: Tween.TransitionType and easing: Tween.EaseType to make it a little bit easier to understand what arguments are you passing in.

you should take a look for a little bit of its documentation, and check what arguments each methods take:
https://docs.godotengine.org/en/stable/classes/class_tween.html

the set_trans and set_ease take specific arguments:

set_trans(trans: Tween.TransitionType)
set_ease(ease: Tween.EaseType)