-- CreateConsole()
function mini_create()
	init_mini(1);
	create_mini(8128);
end;
cango=true
local old1Y = 56;
local new1Y = 78;
local oldre = 10001;
local newre = 10000;
-- CreateConsole()

local step2X = 200;
local Timer2 = 2;
local TiStep = 1;
local old2X = 534;
local new2X = old2X + step2X;

local degree = 45;
local step3 = 0;
local old3 = 0;
local new3 = 0;
mini2lvl=true
local ok = false;

WaitRender();

function gameinput(sender, obj_id, attachedID)
c("sender= "..sender.."\n")

	-- if sender ==6 then	
	-- c(butt)
		-- if	butt == obj.mini_help1.id then
			-- CreateWindow(CWX,CWY,"666",3442,nil,170,250);
			
		-- end;
	-- return end
	MiniInterfaceHandler( sender, obj_id );
	if sender==777 then
	
			StopEmiter("Highlight1");
			flags.mini1_complete = true;
			clear_satelite_leaf("cave");
			flags.most=true;
	end
	
	
	if sender == 33 then		
		CreateWindow(CWX,CWY,"666",686,nil,120,250);			
	end;
	
	if sender==30 then
		if mini_start then
			StopAllEffects()
			setstatemenu()
			StopMusic()
			mini_start=false;
		return;end
		SetCurrentLeaf("cave",2,0);	
		
		ReturnHiddenObjects()      
		DeleteRenderTarget(2234)  					 
		leafobj={}	
		DeleteRenderTarget(2235)  					 
		leafobj={}	
		

		set_visible_object(10144,true);			
		Set_Cursor(1010,3);		
		OpenPlushes()
		mini2lvl=false
		
	return;end
	if sender==26 then
		RemoveWindow(8,2.8,"DestroyMyWindow")
	end
	
	if sender == 10 then
		mini_start=false;
		StopEmiter("Highlight1");
		flags.mini1_complete = true;
		flags.mini1_comp = true;
		flags.start_draw = true;
		
		leafobj={2235}
		GetRenderTarget(2235,"rendertar1");	
		
		function rendertar1(tex_name,tex_id)
			FlipVertical(2235);
			SetAlfa(2235,0,1,0,"vasea3353523")
			SetObjectPosition(2235,0,-256);
			LeaveObjectsOnReder("leafobj");
			ClosePlushes();			
		return end
			
		
		plushes_were_closed = true;
	return; end;
	
	if sender == 28 then
		if new3 == 90 and Timer2 == 1 and oldre == 10000 then
			finish_mini_game(true);
		return; end;
		
	return; end;
	
	if sender==41 then
	if new3 == 90 and Timer2 == 1 and oldre == 10000 then
			finish_mini_game(true);
		return; end;
		
	
	end
	
	
	
	
	if sender == 7 then
		if new3 == 90 and Timer2 == 1 and oldre == 10000 then
			speciale_action(2,10013);			
			finish_mini_game(true);
		return; end;
	return; end;
					
		if sender == 1 then
		-- MiniInterfaceHandler( 1, obj_id );
		
		if obj_id >= 10000 and obj_id <= 10009 and cango then
		cango =false
		StartTimer(222,0.5,"cangou")
		function cangou()
		cango=true
		end
		
			speciale_action(2,obj_id);
			playeffect("039")
			if obj_id == 10000 or obj_id == 10001 then
			
				
				c("old1Y= "..old1Y.."new1Y= "..new1Y.."\n")				
				MoveObjectY(10014,old1Y,new1Y,0.5);
				hh1,hh2=GetObjectPosition(10014)
				--StartTravel(10014,1,nil,nil,{"InstantiationOfLine",2,hh1,old1Y,hh1,new1Y,0.5,false})
				
				local y = new1Y;
				new1Y = old1Y;
				old1Y = y;
				local re = newre;
				newre = oldre;
				oldre = re;
				
				speciale_action(2,oldre);
			return; end;
			
			if obj_id >= 10002 and obj_id <= 10004 then
				playeffect("039")
				if Timer2 + TiStep > 2 or Timer2 + TiStep < 0 then
					TiStep = -TiStep;
					step2X = -step2X;
				end;
				
				Timer2 = Timer2 + TiStep;
				new2X = old2X + step2X;				
				
				MoveObjectX(10014,old2X,new2X,0.5);
				old2X = new2X;
				
				if Timer2 == 0 then
					speciale_action(2,10002);
				return; end;
				if Timer2 == 1 then
					speciale_action(2,10004);
				return; end;
				if Timer2 == 2 then
					speciale_action(2,10003);
				return; end;
				
			return; end;
			
			if obj_id >= 10005 and obj_id <= 10009 then
			playeffect("039")
				SetHotPoint(10014,137,159);
				new3 = old3 + degree;
				if new3 > 180 or new3 < 0 then
					degree = -degree;
					new3 = old3 + degree;
				end;
				
				
				RotateObject(10014,old3,new3,0.5);
				
				old3 = new3;
				
				if old3 == 0 then
					speciale_action(2,10006);
				return; end;
				if old3 == 45 then
					speciale_action(2,10008);
				return; end;
				if old3 == 90 then
					speciale_action(2,10009);
				return; end;
				if old3 == 135 then
					speciale_action(2,10007);
				return; end;
				if old3 == 180 then
					speciale_action(2,10005);
				return; end;
			return; end;
			


		return; end;
	return; end;
return; end;