
AddParticleToObject(1350,"MiniEnd");
MoveEmiter("MiniEnd", 512, 334);
ShowMenu(false);
function mini_create()
	init_mini(1);
	create_mini(8128);
end;

local X1=-1;
local X1=-1;
local X2=-1;
local X3=-1;
local Y = 0;
local x1 = 1.0;
local x2 = 0.0;
local x3 = 0.0;
local y;
local obj;
local xx;
local clean = false;

local cur_x;
local cur_y;

local step1 = 0.1;
local step2 = 0.05;
local step3 = 0.0;
local scX1 = 778;
local scX2 = 861;
local scX3 = 921;
local K1 = 0.2;
local K2 = 0.3;
local K3 = 0.33;
local Alfa = 0;
local Alfa1 = 1;
local Alfa2 = 1;
local Alfa3 = 1;

local polz1 =0;
local polz2=0;
local polz3=0;
local i=2;
local ss=-1;
local X=-1;
local Y=-1;

local n=0;
start_minigame=false

function MessageFromMinigame(nCount,Param1,Param2)
n=n+1
playeffect("054")
if  flags.finish_mini1 then return;end
	X=Param1;
	Y=Param2;
	if Param1==nil then Param1 =0; end
if math.abs(Param1-scX1)<5 then
	Y1=Y;
	Alfa= (math.abs(Y-400)*K1)/100;--0.314
	polz1= math.floor((math.abs(Y-242)*0.235)/10);	
	if (polz1*10)>40  then   ss=(( polz1 ) - (4))*2;    srednee=(polz1-ss)+(polz2)+(polz3) polz1=polz1-ss else srednee=polz1+(polz2)+(polz3)   end	
	if srednee>0 then set_pos_in_img(100025,50*(srednee-1) ,0 ,50,64); end
    if srednee==0 then set_pos_in_img(100025,93*-100 ,0 ,0,0); end

	  
	obj_id=10008;
	SetAlfa(obj_id,Alfa1,Alfa)

	Alfa1= Alfa;
	if Alfa>=0 and Alfa<= 0.1 and (not flags.vzyali) then
		flags.scroll1= true;
	 end;
	if srednee==10 then StartTimer(777,0.2)	flags.finish_mini1=true;	BlockCursor(true) end
end;
if math.abs(Param1-scX2)<5 then

	Y2=Y;
	Alfa= (math.abs(Y-300)*K2)/100;--0.171
	polz2= math.floor((math.abs(Y-242)*0.235)/10);	
	if (polz2*10)>10  then   ss=(( polz2 ) - (1))*2;    srednee=(polz1)+(polz2-ss)+(polz3) polz2=polz2-ss else srednee=polz1+(polz2)+(polz3)   end	
	if srednee>0 then set_pos_in_img(100025,50*(srednee-1) ,0 ,50,64); end
    if srednee==0 then set_pos_in_img(100025,93*-100 ,0 ,0,0); end
	
	obj_id=10009;
	SetAlfa(obj_id,Alfa2,Alfa)	
	Alfa2= Alfa;
	if Alfa>=0 and Alfa<= 0.1 and (not flags.vzyali) then
		flags.scroll2= true;
	end;
	if srednee==10 then StartTimer(777,0.2)	flags.finish_mini1=true;	BlockCursor(true) end
	
end;
if math.abs(Param1-scX3)<5 then
	Y3=Y;
	Alfa= (math.abs(Y-500)*K3)/100;--0.85
	polz3= math.floor((math.abs(Y-242)*0.235)/10);	
	if (polz3*10)>50  then   ss=(( polz3 ) - (5))*2;    srednee=(polz1-ss)+(polz2)+(polz3) polz3=polz3-ss else srednee=polz1+(polz2)+(polz3)   end	
	-- srednee=polz1+(polz2)+(polz3)
	if srednee>0 then set_pos_in_img(100025,50*(srednee-1) ,0 ,50,64); end
    if srednee==0 then set_pos_in_img(100025,93*-100 ,0 ,0,0); end
	obj_id=10010;
	SetAlfa(obj_id,Alfa3,Alfa)	
	Alfa3= Alfa;
	if Alfa>=0 and Alfa<= 0.1 and (not flags.vzyali) then
		flags.scroll3= true;
	end;
	if srednee==10 then StartTimer(777,0.2)	flags.finish_mini1=true;	BlockCursor(true) end
end;
	
	-- if flags.scroll1 and flags.scroll2 and flags.scroll3 then
		
		-- StartTimer(777,1)
		-- BlockCursor(true)
	-- end;

end;
		

function gameinput(sender, obj_id, attachedID)
MiniInterfaceHandler( sender, obj_id );


if sender == 10 then
	mini_start=false;
	flags.mini2 = true;	
	flags.comics2 = true;	
	flags.mini_scan=true;
	
	finish_mini_game(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==777 then
	
	clear_satelite_leaf("lab");	
	flags.mini_micro_complete= true;	
	
	end
	
	
	if sender == 33 then	
	 if flags.first_up_micro then
	 flags.first_up_micro=false			
	CreateWindow(CWX,CWY,"666",434,nil,100,230);			
	return; end;		
	return; end;
	
	if sender == 30 then
		if mini_start then
			StopAllEffects()
			setstatemenu()
			StopMusic()
			mini_start=false;
		return;end
		SetCurrentLeaf("lab",5,0);
		ReturnHiddenObjects()      
		DeleteRenderTarget(2234) 
		DeleteRenderTarget(2235) 
		leafobj={}	
		OpenPlushes()
		StopEmiter( "micro" );
		flags.mini_chemic= true;
		flags.start_draw = false;
		
	return; end;
	if sender == 36 then
		
		finish_mini_game(true);
		BlockCursor(false)
	return; end;
	if sender == 28 then
		if flags.first_up_micro then
				flags.first_up_micro=false
			if obj_id == top_plush_id then
				CreateWindow(CWX,CWY,"666",434,nil,100,230);
			return; end;
		return; end;
	return; end;
	
	
	if sender == 100 then	
	
		if clean then
			clear_satelite_leaf("lab");
			setcurentleaf("lab",5,0);
			
		return; end;
		
		if mousepressed then
		
			WaitRender();
			
		return; end;
		
	return; end;
			
	
	if sender==26 then
	 RemoveWindow(8,2.8,"DestroyMyWindow")	
	end
	if sender == 1 then
		MiniInterfaceHandler( sender, obj_id );
		if obj_id == 10000 or obj_id == 10001 or obj_id == 10002 then
			if obj_id == 10000 then 
				-- playeffect("054")
			EnableMouseMoveEvent(true);
			flags.scr1= true
			flags.otpustili= false			
			flags.vzyali= true	
			flags.scroll1=false
			end;		
			if obj_id == 10001 then 
				-- playeffect("054")
			EnableMouseMoveEvent(true);
			flags.scr2= true
			flags.scroll3=false
			flags.otpustili= false			
			flags.vzyali= true	
			-- WaitRender();
			end;
			if obj_id == 10002 then 
				-- playeffect("054")
			EnableMouseMoveEvent(true);
			flags.scr3= true
			flags.scroll2=false
			flags.otpustili= false			
			flags.vzyali= true	
			-- WaitRender();
			end;
			BeginMoving(obj_id);
			add_to_mouse(obj_id);
			objectid = obj_id;
			mousepressed = true;
			-- WaitRender();
		return; end;
	return; end;
	if sender == 6 then
	EnableMouseMoveEvent(false);
flags.scr1= false
flags.scr2= false
flags.scr3= false
flags.vzyali= false	
		if mousepressed then
			mousepressed=false;	
			flags.otpustili= true			
			flags.vzyali= false			
			RemoveFromMouse(objectid);
			EndMoving(objectid);
		return;end;	
	return; end;
	
	
return; end;

function MouseMove(nCount)
if  flags.finish_mini1 then return;end
if flags.scr1 then
cur_x,cur_y=GetObjectPosition(10000);
	
end
if flags.scr2 then
cur_x,cur_y=GetObjectPosition(10001);
end
if flags.scr3 then
cur_x,cur_y=GetObjectPosition(10002);
end
MessageFromMinigame(2,cur_x,cur_y)

end;