-- energy door
dofile("scripts/entities/songdoorcommon.lua")

songNote1 = 0
songNote2 = 0
songNote3 = 0
songNote4 = 0

function init(me)
	commonInit(me)
	if isFlag(FLAG_SONGDOOR1, 1) then
		entity_setState(me, STATE_OPENED)
	else
		entity_setState(me, STATE_CLOSED)
	end
	setWarpSceneNode("SongCave02", "SONGDOORENTER", "R")
end

function songNote(me, note)
	if entity_isState(me, STATE_CLOSED) then
		songNote1 = songNote2
		songNote2 = songNote3
		songNote3 = songNote4
		songNote4 = note
		--[[
		debugLog(string.format("%d, %d, %d, %d", songNote1, songNote2, songNote3, songNote4))
		]]--
		if songNote1 == 1 and songNote2 == 3 and songNote3 == 7 and songNote4 == 5 then
			voiceInterupt("SongDoor1Open")
			setFlag(FLAG_SONGDOOR1, 1)
			entity_setState(me, STATE_OPEN)
		end
	end
end