extends Node

class_name YarnRunnerNode

var yarnRunner := YarnRunner.new()

export var yarnScript : Resource

func start_script():
	yarnRunner.say_func = funcref(self, "on_new_line")
	yarnRunner.choices_func = funcref(self, "on_choices")
	yarnRunner.yarnScript = self.yarnScript
	yield(yarnRunner.run_all(), "completed")

func on_new_line(line):
	print(line)
	yield(get_tree(),"idle_frame")
	
func on_choices(blocks):
	print(blocks)
	yield(get_tree(),"idle_frame")
	print("Default choice taken : " + str(blocks[0]))

	return blocks[0]
