

scripttable.LevelEnd=function()
	if progress.level9==0 then
		progress.level9=1
		menu.EnableItem(level9i)
		menu.SetItemText(level9i,"")
	end
	FinalTeleport()
end

--scripttable.BossStartPos=function() end

scripttable.LevelStart=function()
	ForeachNamedObject("BossLights",function(o) o:SetFrame(1) end)
	ForeachNamedObject("TeleporterDoor",function(o) o:Lock() end)
	ForeachNamedObject("TeleporterTrigger",function(o) o:SetPosition(10000,10000) end)
	StandardIntro()
end

scripttable.TeleporterDoorTrigger=function()
	ForeachNamedObject("TeleporterDoor",function(o) o:Unlock() end)
	ForeachNamedObject("TeleporterLight",function(o) o:SetFrame(1) end)
end

scripttable.TeleporterSwitch=function()
	ForeachNamedObject("TeleporterLights",function(o) o:SetFrame(1) end)
	ForeachNamedObject("TeleporterTrigger",function(o) o:SetPosition(o:GetStartPos()) end)
end


scripttable.BossTrigger=function()
	ForeachNamedObject("BossLights",function(o) o:SetFrame(0) end)
	ForeachNamedObject("BossDoors",function(o) o:Lock() end)

	local pl=player.GetPlayer()
	pl:SetStartPos(scripttable.TeleportDest[1]:GetPosition())

	ForeachNamedObject("BossSpawner",function(o) 
		local boss=CreateFinalBoss(o:GetPosition()) 
		boss:SetStartPos(scripttable.BossStartPos[1]:GetPosition())
		RegisterObject(boss,"Boss")
		o:Delete() 
	end)
	
	scripttable.BossTrigger=function() end
	while #scripttable.Boss>0 do
		Wait(0.5)
	end

	ForeachNamedObject("BossLights",function(o) o:SetFrame(1) end)
	ForeachNamedObject("BossDoors",function(o) o:Unlock() end)
end