


playeffect("055")
function DeleteRes()
	DeleteResource("fon1");
	DeleteResource("aparat1");
	DeleteResource("kluch1");	
	DeleteResource("kluch2");
	DeleteResource("kluch3");
	DeleteResource("kluch4");
	DeleteResource("kluch5");
		DeleteResource("kluch6");
end;

function mini_create()
	init_mini(1);
	create_mini(8128);
end;		MoveObjectX(20008, 511, 850, 3)
			BlockCursor(true)

function gameinput(sender, obj_id, attachedID)

if not flags.mini_complit then
MiniInterfaceHandler( sender, obj_id );
end
	
	
		
		-------------------


if sender==777 then
	clear_satelite_leaf("labb");

end



if sender==28 then
if obj_id == top_plush_id then
			MoveObjectX(20008, 511, 850, 3)
			BlockCursor(true)
end;	
		if obj_id == 20008 then			
			StartTimer(500,1);
		end;



return;end;
-------------закрылись плашки
	
	-------------------------------
	if sender==26 then	
		RemoveWindow(8,2.8,"DestroyMyWindow")
	end
	
	-------Комикс-----------------
	if sender == 30 then	
		 if mini_start then
			StopAllEffects()
			setstatemenu()
			StopMusic()
			mini_start=false;
		return;end
		 if flags.comics2 then		
		
			SwitchToSheet("gr")
			DeleteElement("gr",obj.bumaga.id)	
			LevelComplete1()
		    return; end;

	return; end;
	-----------------------------
	
	
	
	
	
	if sender == 100 then		
	

			if 	flags.mini2==true then		
		
			
		return; end;
		return;end;
	
	
	
	
		
		
	if sender == 1 then		
		------------Скип------------
		if obj_id == obj.mini_skip.id then
			finish_mini_game(true);					
		end;
			
		-----------------------------
		
		
		
		
		-------Первый ключ, миниигра 1
		if obj_id== obj.kluch2.id and  not flags.mini1  then
			
				speciale_action(2,obj.kluch1.id,true,2)
				
						--flags.mini1=true;	
					
		return; end;
		
		if obj_id==7666 then
			finish_mini_game(true);			
		end			---------------------------------------------------
		
		
		----Мини игра 2-----------------
		if obj_id== obj.kluch3.id and  not flags.mini2 and not flags.mini1  then
							
	
					flags.mini2=true;	
		flags.mini2=false;
			flags.mini_complit=true;
			speciale_action(2,obj.kluch4.id,true)	
			BlockCursor(true);
		return; end;
		
		if obj_id== obj.kluch4.id or obj_id== obj.kluch5.id or obj_id== obj.kluch6.id then
			--CreateWindow(CWX,CWY,"105",5474,nil,100,230);
			itemid=obj_id
		return;end;
	----------------------------------
	
	
		WaitRender();
	return; end; --сендер1
	
	if sender==6 then
		if itemid== obj.kluch4.id or itemid== obj.kluch5.id or itemid== obj.kluch6.id then
			CreateWindow(CWX,CWY,"105",5474,nil,100,230)
			itemid=-1
		end
	end
	
	
	if sender == 10 then
	flags.start_draw = true;
	flags.mini1_complete=true;
	ClosePlushes();
		mini_start=false;
	plushes_were_closed = true;
return; end;
	
	
	if sender ==36 then
	
	if obj_id ==500 and not flags.mini1_complete then
	
	speciale_action(2,obj.aparat1.id,true,3);	
Set_Cursor(obj.kluch2.id,4);playeffect("057")	
	return;end;
	
	if obj_id==3000 then
	flags.kluch=false;
	BlockCursor(false);
				speciale_action(2 ,obj.kar.id ,true);
				speciale_action(4 ,7655 );
				set_visible_object(7655,true)				
		set_visible_object( obj.mini_border.id, false );		
		set_visible_object( obj.mini_skip2.id, false );
		set_visible_object( obj.mini_help2.id, false );
		set_visible_object( obj.mini_skip_loading.id, false );
		set_visible_object( obj.mini_menu2.id, false );
		set_visible_object( obj.mini_skip1.id, false );
		set_visible_object( obj.mini_help1.id, false );
		set_visible_object( obj.mini_menu1.id, false );
		set_visible_object( obj.mini_skip.id, false );
		set_visible_object( obj.mini_help.id, false );
		set_visible_object( obj.mini_menu.id, false );			
	
	return;end;
	
 if	flags.mini_complit then
 flags.mini_complit=false;
	--	speciale_action(2,obj.kluch4.id,true)
		end;
	
	return;end;
	
		if sender ==15 then
		
		if obj_id ==obj.aparat1.id then
			speciale_action(2,obj.kluch5.id,true);
			set_visible_object( obj.kluch2.id, false );	
			playeffect("056")			
		
		return;end;
				
		if obj_id== obj.kluch4.id  then
			
				speciale_action(2,obj.kluch6.id,true);
				playeffect("056")				
		return; end;
		
			if obj_id== obj.kluch6.id  then
			
				speciale_action(2,obj.kluch5.id,true)
				playeffect("056")			
			
							
		return; end;
		if obj_id== obj.kluch5.id  then
			
		ColorCallaps(obj.kluch3.id,100,5);
		
		StartTimer(3000,2.5);
		flags.kluch=true;
		return;end;
		
		return;end;
	if sender==35 and not flags.kluch then
	if obj_id==obj.kluch2.id then
setcolor(obj.kluch2.id,0.2,0.8,1,1)

end
	if obj_id==obj.kluch3.id then
setcolor(obj.kluch3.id,0.2,0.8,1,1)

end
	if obj_id==obj.kluch4.id then
setcolor(obj.kluch4.id,0.2,0.8,1,1)

end
	if obj_id==obj.kluch5.id then
setcolor(obj.kluch5.id,0.2,0.8,1,1)

end
	if obj_id==obj.kluch6.id then
setcolor(obj.kluch6.id,0.2,0.8,1,1)

end
		if obj_id==7655 and not flags.kluch then
			set_visible_object(7655,false)		
			speciale_action(4,7666)
			set_visible_object(7666,true)	
		end	
	end

if sender==39  then
	if obj_id==obj.kluch2.id then
setcolor(obj.kluch2.id,1,1,1,1)

end
	if obj_id==obj.kluch3.id then
setcolor(obj.kluch3.id,1,1,1,1)

end
	if obj_id==obj.kluch4.id then
setcolor(obj.kluch4.id,1,1,1,1)

end
	if obj_id==obj.kluch5.id then
setcolor(obj.kluch5.id,1,1,1,1)

end
	if obj_id==obj.kluch6.id then
setcolor(obj.kluch6.id,1,1,1,1)

end
	if obj_id==7666 and not flags.kluch then
		set_visible_object(7666,false)
		set_visible_object(7655,true)
	end	
end

	-----Объект стал видимым
	if sender ==16 then
	
	
	----------Апарат------
	if obj_id== obj.aparat1.id  then
			
				speciale_action(2,obj.kluch2.id,true,3)
				playeffect("057")				
		return; end;
		---ключ----
		if obj_id== obj.kluch2.id  then
			
					CreateWindow(CWX,CWY,"666",23423,nil,100,230);
					BlockCursor(false);
							
		return; end;
		
		
	--------------------------
	
		
		
		if obj_id== obj.kluch5.id  then
			playeffect("056")	
				speciale_action(2,obj.kluch6.id,true)
						
		return; end;
		
			if obj_id== obj.kluch6.id  then
			playeffect("056")	
				speciale_action(2,obj.kluch4.id,true)
						
		return; end;
		
		
			if obj_id== obj.kluch4.id  then
			playeffect("056")
				speciale_action(2,obj.kluch3.id,true)
							
		return; end;
		
		


--------Ключ 2--------------	
		if obj_id== obj.kluch1.id  then
			playeffect("056")
			--	speciale_action(2,obj.kluch5.id,true);
			set_visible_object( obj.kluch2.id, false );	
			
			speciale_action(2,obj.aparat1.id,true,3);
					
							
		return; end;
-------------------------------		
	
	
	return;end;
	
	
return; end;

