- Edited
Hello again Godot forum!
I have a rather confusing ( well for me ) question this time. I am making a dialog box for my game and while making it I decided that I wanted to be able to edit the text for the box as a export variable, instead of in the script itself. I tried multiple different implements, but nothing is seeming to work. Instead of reading the lines, it just reads nothing and only displays the first letter ( I am pretty sure it is doing that, because I changed the text to a sting to export it ( I think at least )). Anyway here is the code. Also if anyone can tell me how to add a sound when the text is scrolling ( like in undertale ) and when you press "ui_accept"( for switching to the next set of dialog ), that would be a big help! Well, I am going to get back to work, all relevant code is below.
extends Control
export(String, MULTILINE) var text # this was added after the fact
#var dialog =
#[
# 'basic text.',
# ' basic text 2',
# 'basic text 3'
#]
var dialog = [
text
]
var dialog_index = 0
var finished = false
func _ready():
load_dialog()
func _process(delta):
$"next-indicator".visible = finished
if Input.is_action_just_pressed("ui_accept"):
load_dialog()
func load_dialog():
if dialog_index < dialog.size():
finished = false
$RichTextLabel.bbcode_text = text[dialog_index] #dialog[dialog_index]
$RichTextLabel.percent_visible = 0
$Tween.interpolate_property( $RichTextLabel, "percent_visible", 0, 1, 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT )
$Tween.start()
else:
queue_free()
dialog_index += 1
func _on_Tween_tween_completed(object, key):
finished = true