Connected the dialog box to the NPC

This commit is contained in:
2026-03-11 16:54:12 +11:00
parent 21141376d2
commit 94b810e4f1
3 changed files with 16 additions and 5 deletions

View File

@@ -3,9 +3,7 @@ extends Node
@export var dialogContainer: MarginContainer
@export var dialogTextLabel: RichTextLabel
const INCREMENT: float = 0.01
func set_dialog(text: String) -> void:
func set_dialog(text: String, seconds: float = 1) -> void:
dialogTextLabel.text = text
dialogTextLabel.visible_ratio = 0
var ratio: float = 0
@@ -16,10 +14,12 @@ func set_dialog(text: String) -> void:
else:
dialogContainer.visible = true
var increment: float = (1 / seconds)/ 60.0
while true:
#don't interfere with other timers
if dialogTextLabel.visible_ratio < ratio or dialogTextLabel.visible_ratio >= 1:
return
dialogTextLabel.visible_ratio += INCREMENT
dialogTextLabel.visible_ratio += increment
ratio = dialogTextLabel.visible_ratio
await get_tree().create_timer(INCREMENT).timeout
await get_tree().create_timer(1.0/60.0).timeout #update proportional to 60 FPS