extends CanvasLayer
@onready var dialognode = $dialog
@onready var dialogtext = $dialog/dialog
@onready var dialogbox = $dialog/box
@export var done = false
enum typestate {TYPING,FINISHED, CF}
signal dialog_finished
var statetype = typestate.FINISHED
var dialogon = false
var state = 0
var lineslength = 0
var lines : Array = []
func hide_dialog():
dialognode.visible = false
dialogtext.text = ""
func show_dialog():
dialognode.visible = true
func add_text(text: String):
dialognode.visible = true
statetype = typestate.TYPING
dialogtext.text = text
dialogtext.visible_characters = 0
for i in range(text.length() + 1):
dialogtext.visible_characters = i
await get_tree().create_timer(0.04).timeout
statetype = typestate.FINISHED
func dialog(liness : Array ):
done = false
lines = liness
lineslength = lines.size()
dialogon = true
state = 0
show_dialog()
add_text(lines[state])
func _ready() -> void:
hide_dialog()
func _input(event: InputEvent) -> void:
if event.is_action_pressed("next"):
if statetype == typestate.TYPING :
print("nah")
return
if dialogon == true:
if lineslength -1 == state:
dialog_finished.emit()
hide_dialog()
state = 0
done = true
dialogon = false
statetype = typestate.CF
else:
print("yes")
dialogtext.text = ""
state = state + 1
add_text(lines[state])
**PICTURE 1 **
thats the node tree of the system