Now About Social Code
summaryrefslogtreecommitdiff
path: root/scripts/ui.gd
blob: eaf2d0cb354510bdaac12728f3ee67f37fd4a452 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
extends CanvasLayer

@export var player: Node3D

var timeout: float = 0
var timeout_counter: float = 0

# Called when the node enters the scene tree for the first time.
#func _ready() -> void:
#	pass # Replace with function body.

func have_toast() -> bool:
	return timeout > 0

func set_toast(text: String, p_timeout: float) -> void:
	$Toast.text = text
	
	if p_timeout != 0:
		timeout = p_timeout
		timeout_counter = 0

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	$Ammo.text = "Ammo " + str(player.ammo)
	
	if timeout > 0:
		if timeout_counter < timeout:
			timeout_counter += delta
		else:
			$Toast.text = ""
			timeout = 0