extends Node2D

onready var global: Node = get_node("/root/Global")

onready var sprite: Sprite = $Sprite

func _ready() -> void:
	if global.game_vars.has("crystal_used"):
		sprite.frame = 1

func _input(event) -> void:
	if !event is InputEventMouseButton:
		return
	if !event.pressed:
		return
	if event.button_index != BUTTON_LEFT:
		return
	if global.game_vars.has("crystal_used"):
		sprite.frame = int(min(sprite.frame+1, sprite.hframes-1))
		if sprite.frame == 2:
			global.play_sound("inventory_open")
