
function InitGlobalVariables()
	done = 1
	stage = 0
	cur_timer = 0
	wait_timer = 10
	stage_init = true
end

function OnEnter()

	InitGlobalVariables()
	LG_GameController("LoadLevel","data\\levels\\test.txt")
	LG_GameUI("ScreenFadeIn", 1, 1, 1, 2)

		
	LG_Camera("SetPosition",559.56, -224.55, 239.80, "true")
	LG_Camera("SetTarget",465.72, -191.79, 228.74, "true")
	
end

function DoStop()
	done = 0

end

function OnExit()
	
	LG_GameUI("ScreenFadeOut", 1, 1, 1, 2)
	LG_GameController("RunScript","data\\scripts\\test.lua")
end

OnEnter()

while (done>0) do

	local time = LG_GameController("GetTime")

	if (stage==0) then
		
		if(stage_init) then
			local x
			local y
			local z
			x,y,z = LG_Camera("GetRight")
			x,y,z = LG_Math("MultiplyVec3",x,y,z,-50);
			LG_Camera("SetVelocity", x, y, z,"true","true")
			stage_init = false
			LG_Misc("SetWait", 5)
		
		else 
			local ret = LG_Misc("CheckWait", time)
			if(ret > 0) then
				stage = stage + 1;
				stage_init = true
				LG_Camera("SetVelocity", 0, 0, 0,"true","true")
				LG_Camera("SetPosition",-100.40, 710.37, 367.92, "true")
				LG_Camera("SetTarget",-60.73, 626.02, 331.68, "true")
			end
		end

	elseif (stage==1) then
		
		if(stage_init) then
			local x
			local y
			local z
			x,y,z = LG_Camera("GetRight")
			x,y,z = LG_Math("MultiplyVec3",x,y,z,-50);
			LG_Camera("SetVelocity", x, y, z,"true","true")
			stage_init = false
			LG_Misc("SetWait", 7)
		
		else 
			local ret = LG_Misc("CheckWait", time)
			if(ret > 0) then
				stage = stage + 1
				stage_init = true
				LG_Camera("SetVelocity", 0, 0, 0,"true","true")
				LG_Camera("SetPosition",157.20, -161.24, 93.32, "true")
				LG_Camera("SetTarget",196.87, -245.58, 57.08, "true")
			end
		end

	elseif (stage==2) then
		
		if(stage_init) then
			local x
			local y
			local z
			x,y,z = LG_Camera("GetForward")
			x,y,z = LG_Math("MultiplyVec3",x,y,z,50);
			LG_Camera("SetVelocity", x, y, z,"true","true")
			stage_init = false
			LG_Misc("SetWait", 5)
		
		else 
			local ret = LG_Misc("CheckWait", time)
			if(ret > 0) then
				stage = stage + 1
				stage_init = true
				LG_Camera("SetVelocity", 0, 0, 0,"true","true")
			end
		end
	
	elseif(stage ==3) then
		done = 0
	end
	
	key = LG_Misc("GetKeyInput")
	if(key>0) then
		done = 0
	end

--	LG_Debug("SetWindowText",2,stage,key)
	LG_Script("Yield")
end

LG_Script("Stop")

OnExit()

