How to use Augments correctly?

Godot Version

Question

So i have this function in my Hud scene and I’m planning to change the display text. So i only need this one function and when is called it should contain a display_time and Update: Double_Jump or Sprint or XY:

but i dont know what i should add, to tell the function. Okay display and text should be “Double jump press space” or “Sprint Press XY”

i thought of something like
match
jump:
text.line = XY
Sprint:
text.line = YZ

But thats the right syntax to use a string in the () like this display time.

i think there must be a easy solution, but im a newbie to coding

func display_controlling_hint(display_time:float):
	animation_player.play("show_controlling_hint")
	await get_tree().create_timer(display_time).timeout
	animation_player.play_backwards("show_controlling_hint")
	await animation_player.animation_finished
	controlling_display_panel.visible = false
1 Like

I think i found a good solution by myself, but i case anybody founds this post later via google etc.

func display_conlling_hint(display_time:float, update:String):
	match update:
		"SPRINT":
			controlling_label.text = "Press Shift to Sprint"
		"ATTACK":
			controlling_label.text = "Press Q to attack"
		_:
			controlling_label.text = "Error, String not Found"
			#where the function get called, is a wrong string 
		
	animation_player.play("show_controlling_hint")
	await get_tree().create_timer(display_time).timeout
	animation_player.play_backwards("show_controlling_hint")
	await animation_player.animation_finished
	controlling_display_panel.visible = false

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.