This repository has been archived on 2024-04-19. You can view files and clone it, but cannot push or open issues or pull requests.
Jessist/addons/dialogue_manager/dialogue_resource.gd
2022-06-18 13:05:48 +02:00

33 lines
1.3 KiB
GDScript

extends Resource
class_name DialogueResource
const DialogueLine := preload("res://addons/dialogue_manager/dialogue_line.gd")
const DialogueConstants := preload("res://addons/dialogue_manager/constants.gd")
export(int) var syntax_version
export(String) var raw_text
export(Array, Dictionary) var errors
export(Dictionary) var titles
export(Dictionary) var lines
func _init():
syntax_version = DialogueConstants.SYNTAX_VERSION
raw_text = "~ this_is_a_node_title\n\nNathan: This is some dialogue.\nNathan: Here are some choices.\n- First one\n\tNathan: You picked the first one.\n- Second one\n\tNathan: You picked the second one.\n- Start again => this_is_a_node_title\n- End the conversation => END\nNathan: For more information about conditional dialogue, mutations, and all the fun stuff, see the online documentation."
errors = []
titles = {}
lines = {}
func get_next_dialogue_line(title: String) -> DialogueLine:
# NOTE: For some reason get_singleton doesn't work here so we have to get creative
var tree: SceneTree = Engine.get_main_loop()
if tree:
var dialogue_manager = tree.current_scene.get_node_or_null("/root/DialogueManager")
if dialogue_manager != null:
return dialogue_manager.get_next_dialogue_line(title, self)
assert(false, "The \"DialogueManager\" autoload does not appear to be loaded.")
return null