extends BasisInteraction

var is_talking = false

export var yarnScript : Resource

export var speechPanel_path : NodePath
onready var speechPanel := get_node(speechPanel_path)

var yarnRunner := YarnRunner.new()

func on_interact():
	if not is_talking:
		yarnRunner.say_func = funcref(speechPanel.text, "on_new_line")
		yarnRunner.choices_func = funcref(speechPanel.choices, "on_choices")
		yarnRunner.yarnScript = self.yarnScript
		
		is_talking = true
		speechPanel.show()
		Controller.player_input_enabled = false
		
		yield(yarnRunner.run_all(), "completed")
		
		Controller.player_input_enabled = true
		speechPanel.hide()
		is_talking = false
