dofile("scripts/entities/entityinclude.lua")

lamp = 0
door = 0

function init(me)
	node_setCursorActivation(me, false)
end

function activate(me)
end

function update(me, dt)
	if lamp == 0 then
		lamp = node_getNearestEntity(me, "songlamp1")
	end
	if door == 0 then
		door = node_getNearestEntity(me, "EnergyDoor")
	end
	if lamp ~= 0 and entity_isState(lamp, STATE_ON) then		
		if door ~= 0 and not entity_isState(door, STATE_OPEN) and not entity_isState(door, STATE_OPENED) then
			entity_setState(door, STATE_OPEN)
		end
	end
end
