local step = 0;
local flag = true;

rem=-1;
gg=290;
help=false;
BlockCursor(true)
mini1lvl10=true
function DeleteRes()
	
end;

function mini_create()
	init_mini(true);
	create_mini(8128);
end;
for i=1,4,1 do
set_pos_in_img(10024+i,0,0 ,93,93);
Fields1[i]=false
end;


function gameinput(sender, obj_id, attachedID)
MiniInterfaceHandler( sender, obj_id );
	if sender == 10 then -- the end
		 finish_mini_game(false)
		 mini1lvl10=false
		BlockCursor(true)
		StartTimer(8882,1);
			mini_start=false;
	
	return; end;
	
		if sender==26 then
			RemoveWindow(8,2.8,"DestroyMyWindow")
		help=false;
		end
	
	  if sender == 36 then  
    if obj_id == 8882 then
			
		flags.mini1_complete = true;
		flags.mini11_complite=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 obj_id==11111 then
			 BlockCursor(false)
			 step = 0
		for i=1,4,1 do
			setcolor(10024+i,1,1,1,1);
			set_pos_in_img(10024+i,0,0 ,93,93);
			Fields1[i]=false
		end;
		if not err then
			finish_mini_game(true)
		end;
		if err then
			speciale_action(2,10001)
		end;
		return;end;
   return; end;	
	if sender == 33 then	
	if flags.first_up_cod2 then
			flags.first_up_cod2= false;			
				CreateWindow(CWX,CWY,"666",454,nil,100,195);
				for i=1,4,1 do
					set_pos_in_img(10024+i,0,0 ,93,93);
					Fields1[i]=false
				end;
			
		return; end;
		
	if flags.mini1_complete then
	
		end;
		
	return; end;
	
	if sender==777 then
		
			
			flags.mini_go =false;
			flags.mini1_complete = true;
			flags.mini11_complite=true;
			
			
			clear_satelite_leaf("museum");	
			BlockCursor(false)
					
	end
	
	if sender == 30 then	
			if mini_start then
			StopAllEffects()
			setstatemenu()
			StopMusic()
			mini_start=false;
			return;end
			for i=100,104,1 do
					set_visible_object(i,false)
				end
			flags.comics3 = true;
			flags.start_draw = true;
			flags.mini=true----------------------перенести в комикс
			flags.mini1=true----------------------перенести в комикс	
			BlockCursor(false)
			SetCurrentLeaf("museum",10,0);
			ReturnHiddenObjects()      
			DeleteRenderTarget(2234)  	
			DeleteRenderTarget(2235)
			leafobj={}	
		
			
			OpenPlushes()
			
		
				
			
			
	return;end;

	if sender == 1 then
	
	if obj_id==obj.mini_help1.id then
		
	return;end
	
	if obj_id==obj.mini_menu1.id then	return;end
		if obj_id== 9999 then
			if step==0 then
				for i=1,4,1 do
					set_pos_in_img(10024+i,0,0 ,93,93);
					
					playeffect("080")
					Fields1[i]=false
				end;
			return; end;
			if step>0  then
				n=(10024+step)
				p=(obj_najat-10001)
				set_pos_in_img(n,0,0 ,93,93);
				
				step=step-1
			return; end;
		return; end;
		
				step=step+1;
				
			if obj_id>=10002 and obj_id<=10011 then
			playeffect("079")
			n=(10024+step)
			p=(obj_id-10001)
						
			
			
		
				set_pos_in_img(n,93*p,0 ,93,93);
				speciale_action(2,obj_id);				
				obj_najat=obj_id
				flags.najat=true
				Fields3[step]=p;		
	
			-- set_visible_object(p,true);
			 -- SetObjectPosition(p,gg,73)
			 -- gg=gg+20;
				if step<5 then
					if p==Fields2[step] then
						Fields1[step]=true;
					end;
				end;
			end;	

	end;
	if sender == 6 then
	if flags.najat then
		speciale_action(2,obj_najat)
		flags.najat=false
	 end;	
	
	 if step==4 then
	 
	for i=100025,100029 do
	setcolor(i,1,1,1,1)
	-- set_visible_object(i,false);
	end
	
	 BlockCursor(true)
		err=false;
		for i=1,4,1 do
			if not Fields1[i]   then
			
				setcolor(10024+i,0.6,0,0.1,1);				
				err=true;				
				
				set_visible_object(Fields3[i+1],true);
				set_pos_in_img(100024+i,57*(Fields3[i]-1),0 ,40,93);
				setcolor(100024+i,0,0,0,1)				
				
				
				if Fields3[i]==7 then				
				setcolor(10024+i,1,0.8,0,1)
				
				end
				if Fields3[i]==6 then				
				setcolor(10024+i,1,0.8,0,1)
	
				end
				if Fields3[i]==0 then				
				setcolor(10024+i,1,0.8,0,1)
				
				end
				if Fields3[i]==1 then				
				setcolor(10024+i,1,0.8,0,1)
			
				end
				
				
				else	
				set_visible_object(Fields3[i],true);
				set_pos_in_img(100024+i,57*(Fields3[i]-1),0 ,40,93);
				setcolor(100024+i,0,1,0,1)			
			end;
		end;
		if not err then
			speciale_action(2,10000)
			playeffect("081")
		end;
		if err then
			speciale_action(2,10001)
			playeffect("082")
		end;		
		StartTimer(11111,1.5)

	 return;end;
	else
	gg=290;	
	end;

return; end;
