extends RichTextLabel @onready var message_timer = $MessageTimer @onready var json_content: Dictionary @onready var message_lines: Dictionary @onready var messages_seen: Array @onready var lines_file_path = "res://text/message_lines.json" @export var lines_displayed = [] signal end_introduction # Called when the node enters the scene tree for the first time. func _ready(): set_scroll_follow(true) # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(_delta): pass func show_message_by_id(section: String, idnum: int): var unique_id = section + str(idnum) if unique_id not in messages_seen: show_message(message_lines[section][idnum]) messages_seen.append(unique_id) func show_message(msg): lines_displayed.append(_centered_message(msg)) #var new_text = _nl_append(message.text, _centered_message(msg)) text = ("\n").join(lines_displayed) show() func _nl_append(msg1, msg2): return msg1 + "\n" + msg2 func _centered_message(msg): return "[center]" + msg + "[/center]" func display_introduction(): print("Displaying introduction.") show_message_by_id("introduction", 0) await get_tree().create_timer(1.0).timeout show_message_by_id("introduction", 1) await get_tree().create_timer(0.5).timeout end_introduction.emit() func _on_interface_ready(): print("Narration received interface_ready signal.") var main_sequence_messages = json_content["main_sequence_messages"] print("Got JSON content keys " + ", ".join(main_sequence_messages.keys())) for section in main_sequence_messages.keys(): message_lines[section] = [] var section_lines = main_sequence_messages[section] section_lines.sort_custom(func(a,b): return a["id"] < b["id"]) for line in section_lines: message_lines[section].append(line["text"]) display_introduction()