crabs-game/scripts/DialogueAction.gd
2020-08-20 18:52:24 +02:00

25 lines
603 B
GDScript

extends Node
class_name DialogueAction
signal end
export (NodePath) var dialogue_box_path
onready var dialogue_box = get_node(dialogue_box_path)
export (String, FILE, '*.json') var dialogue_file_path : String
func start() -> void:
var dialogue : Array = load_dialogue(dialogue_file_path)
dialogue_box.start(dialogue)
yield(dialogue_box, "end")
emit_signal("end")
func load_dialogue(file_path) -> Array:
var file = File.new()
# assert (file.file_exists(file_path))
file.open(file_path, file.READ)
var dialogue = parse_json(file.get_as_text())
assert (dialogue.size() > 0)
return dialogue