0 votes

I have a RPG dialogue box scene on autoload. I use it to display dialogue on all game scenes. The problem is that if i do this:

Dialog.Dialog = ["messagle1", "message2"]
Dialog.start("Person")

Dialog.Dialog = ["messagle1", "message2"]
Dialog.start("Person")

The code will not wait for the first function to finish and then put the new messages in the variable Dialog. Do you have any idea on how i could solve this?

The full code for the dialogue script:

extends CanvasLayer

var Dialog = [
'default text',
'default text2',
]

var dialog_count = 0
var finished = false

func _ready():
$Control.visible = false

func process(delta):
if Input.is
actionjustpressed("uiaccept"):
if increment():
display
diag()
if Input.isactionjustpressed("uiright"):
if increment():
displaydiag()
if Input.is
actionjustpressed("uileft"):
if decrement():
display
diag()

func start(persoana):
finished = false
$Control/RichTextLabel2.bbcodetext = persoana
dialog
count = 0
display_diag()

func finished():
$Control.visible = false
finished = true

func increment():
if dialogcount < Dialog.size()-1:
dialog
count += 1
return true
else:
finished()

func decrement():
if dialogcount > 0:
dialog
count -=1
return
else:
finished()

func displaydiag():
$Control.visible = true
$Control/RichTextLabel.bbcode
text = Dialog[dialogcount]
$Control/RichTextLabel.percent
visible = 0
$Control/Tween.interpolateproperty(
$Control/RichTextLabel, "visible
characters", 0, 187, 7,
Tween.TRANSLINEAR, Tween.EASEIN_OUT
)
$Control/Tween.start()

func onTweentweencompleted(object, key):
pass

in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.