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

n = 0
ent = 0
done = false

function init(me)

	n = getNaija()
end

function activate(me)
end

function update(me, dt)
	if ent == 0 then
		node = getNode("OPENFINALDOOR")
		if node ~= 0 then
			ent = node_getNearestEntity(node, "FinalDoor")
		end
	end
	
	if not done then
		if node_isEntityIn(me, n) and not (entity_isState(ent, STATE_CLOSED) or entity_isState(ent, STATE_CLOSE)) then
			entity_setState(ent, STATE_CLOSE, -1, 1)
			done = true
		end
	end
end
