
local v = false;

AddParticleToObject(obj.ascan.id,"scan");
MoveEmiter("scan",494+60,390+18);

WaitRender();

function gameinput(sender,obj_id,attachedID)
 if (sender == 1  or sender==5) and not isTimes  and imagetex~=-1 then
			set_visible_object(obj.plashechka.id,false)
			set_visible_object(obj[imagetex].id,false)
			del_object_from_game(5654547)		
			gameinput(26,imageid)	
			
	end
if sender ==41 then	
	RotateHandler(obj_id);	
if obj_id ==obj.dragonfly.id then	
	StartAnimation( 5555555555,1,5 );
	return;end;	
	return;end;
	
	
---сендер 1---------------------------	
if sender == 1 then		

----------Ключ применяем на сканер
if obj_id ==obj.ascan.id then
	if scaner_on then
					CreatePlashechka(9999,"70","goodgirl")
	return;end;
if attachedID == obj.bumaga.id then
				takeobjecttohand=false
             RemoveFromMouse(attachedID);
             DeleteElement("gr",attachedID);
             StopEmiter("scan");
			flags.bumaga=true;
			ClosePlushes();
			HideGlove()
			HideScaner()
			flags.ministart=true;
			ShowMenu(false);
			flags.ministart1=true
else
	CreatePlashechka(9999,"104","prof")
return;end;

return;end;
---------------------------

return; end;--конец 1 сендера

	if sender == 2 then
		RemoveFromMouse(object);
		MessageProc(sender,obj_id);
	return;end;		

	if sender == 14 then -- Menu click	
		-- takeobjecttohand=true
		if not scaner_on then
	 	addObjectToMouse(obj_id);	
		end
	return; end;
	
	--правая кнопка---------------------
	if sender == 8 then
	takeobjecttohand=false
		HideGlove();	
			HideScaner();
			HideRentgen()
		HideNvg();
	return end;
-----------------------------------	

	if sender ==26 then
--конец уровня	
	if obj_id ==50 then
			flags.finish=true;
			
			if obj.bumaga.is_stored then
			UnStoreObj(obj.bumaga.id);		
			end;
			DeleteElement("gr",159)	
			flags = {};	
			flags.glove_taken = true;	
			flags.rentgen_taken = true;
			flags.nvg_taken = true;
			flags.pointer_taken = true;
			flags.scaner_taken = true;
			flags.restore_sheet = false;	
			
			UnStoreObj(obj.bumaga.id);	
			LevelEnd(36)
		end
	
	end
	
	if sender==777 then
	
	StartTimer(43334342,0.3,"switchgr")
			function switchgr()			
				SwitchToSheet("gr")
			end		
			
	--начало уровня
	if  flags.comics then			
		StartTimer(43342,0.5,"conv17")
			function conv17()
				CreatePlashechka(79,"102","prof")	
				SwitchToSheet("gr")
			end		
		
		ShowMenu(true)
		SwitchToSheet("gr")
		flags.comics=false;		
	return;end
	
--старт мини	
	if flags.ministart1 and not flags.mini1_complete then	    
		leafobj={2234}
		GetRenderTarget(2234,"rendertar");	
		mininame="mini";
		mininum1=17;
		mininum2=10;
		mininame2="labb";			
	return;end;
	if top_plush_id then		
		ShowMenu(true)
		
	end	
	end

	
	if sender == 100 then
		
		
	
			
			
		if  not flags.bumaga then

			flags.bumaga= true;
			AddElement(sheet,obj.bumaga.id);
			MoveObjectToTree(obj.bumaga.id);
			obj.bumaga.is_stored = true;
		end	
		
		
		
	
	
            if flags.mini1==false then
			
			StartEmiter( "scan" );
			else
			
			end;
		
	
		if flags.first_time_load then
			
				flags.first_time_load=false
			set_visible_object(obj.intro.id,true);
			speciale_action(4,obj.intro.id);
			flags.start_draw = false;
		return; end;
					
return; end;
	

	
	if sender == 33 then	
		if not flags.finish then
		flags.finish = false;
			ShowMenu(true);
			SwitchToSheet("gr");
		return end		
		
	return;end;
------------------------------------	



return; end; 



function SelectRandom()
local dist=-1;local a=-1;local b=-1;local v=100;local t=-1;local diag=-1;
local width = -1;local height = -1;local radius=1.2;
				
	if flags.scan then	
	computation(obj.ascan.id);		
	return end
	
	ok = false
	while not ok do
		help_id = GetRandomObject();
		for i,v in pairs(obj) do
			if v.id == help_id and not v.is_collapsed then
				ok = true
				x,y=GetObjectPosition(v.id);
				x1,y1=GetObjectPosition(obj.dragonfly.id);
				width,height = GetObjectSize(v.id)
				a= (x-x1); b= (y-y1);  dist= math.sqrt (a^2+b^2);				
		        t=dist/400;		
                r = (math.sqrt(width^2+height^2)*0.5);		
				
				if r<50 then	r=75;	radius=4;	end  -- при радиусе меньше 50 определяем время кружения и радиус стрекозы
				
				if r>50 and r <100 then	r=87 radius=2.5;  end  --при радиусе больше 50 и меньше 100
				
				if r>100 then 	r=100 	radius=0.75;  end  -- при радиусе больше 100
				
				StartBigTravel(obj.dragonfly.id, v.id, 0, t, r/70, t, 3 ,radius);
			return end
		end
	end
end;

