crabs-game/scripts/DialogueAction.gd

25 lines
603 B
GDScript3
Raw Permalink Normal View History

2020-08-16 08:50:04 +02:00
extends Node
class_name DialogueAction
signal end
2020-08-16 08:50:04 +02:00
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()
2020-08-20 18:52:24 +02:00
# assert (file.file_exists(file_path))
2020-08-16 08:50:04 +02:00
file.open(file_path, file.READ)
var dialogue = parse_json(file.get_as_text())
assert (dialogue.size() > 0)
return dialogue