xyz Okay, here is the code
extends Control
var textToReveal: String = "This is the text to be revealed"
var STATUS_PROCESS : bool
var STATUS_DONE : bool
var revealInterval: float = 0.05
var visible_letters : int = 0
var pressed_z = 0
func _ready():
$Timer.wait_time = revealInterval
STATUS_DONE = true
STATUS_PROCESS = false
func _input(event):
if STATUS_DONE == true:
if event.is_action_pressed("ui_accept"):
pressed_z += 1
if pressed_z == 1:
$Label.text = ""
visible_letters = 0
$Timer.start()
STATUS_DONE = false
STATUS_PROCESS = true
elif pressed_z == 2:
visible_letters = 0
pressed_z = 0
STATUS_DONE = true
$Label.text = ""
elif STATUS_DONE == false:
if Input.is_action_just_released("ui_accept"):
if pressed_z == 1:
$Label.text = textToReveal
$Timer.stop()
STATUS_DONE = true
STATUS_PROCESS = false
print("Skipped text")
func _on_timer_timeout():
if visible_letters < textToReveal.length():
var letter = textToReveal[visible_letters]
$Label.text += letter
if letter != " ":
$AudioStreamPlayer.play()
visible_letters += 1
elif letter == " ":
visible_letters += 1
else:
STATUS_DONE = true
print("Printing finished")
$Timer.stop()
I am trying to make that a global function, but the downsides are it requires a AudioStreamPlayer, a Label and a Timer. I tried to make it so I make a global variable that integrates the timeout inside the global function and uses variables as nodes. For the Label and AudioStreamPlayer I tried replacements that are working properly but the timer won't work and the lambas thing is a bit confusing. Can I make that whole process into a single function?
btw, it is for making a dialogue that is written progressively, like in Professor Layton