help=false;
skipping=false;

function set_rainbow_color(step,color)
		if color=="red" then
		   setcolor(step+1031,1,0,0,1);
		return;end;  
		if color=="orange" then
		   setcolor(step+1031,0.95,0.8,0,1);
		return;end;  
		if color=="yellow" then
		   setcolor(step+1031,0.9,0.9,0.2,1);
		return;end;  
		if color=="green" then
		   setcolor(step+1031,0,1,0,1);
		return;end;  
		if color=="blue" then
		   setcolor(step+1031,0.1,0.5,0.6,1);
		return;end; 
		if color=="darkblue" then
		   setcolor(step+1031,0,0,1,1);
		return;end;   
		if color=="purple" then
		   setcolor(step+1031,0.4,0,0.8,1);
		return;end;  
end;

function check_switch(switch_id,step_ok,img_id,color)
		playeffect("handle");
		if not switch[switch_id] then
		   switch[switch_id]=true;	
		   set_pos_in_img(img_id-16,0,112,64,112);	
		   set_rainbow_color(step,color)
		   if step~=step_ok then
			  error_switch[step]=true;
		   end;
		   step=step+1;
			if step==8 then		   
				check_switches(true);
			end;	
		return;end;  
		   switch[switch_id]=false;
		   set_pos_in_img(img_id-16,0,0,64,112);
		   step=step-1;		
		   setcolor(step+1031,0.5,0.5,0.5,1);
		   error_switch[step]=false;
		   	
end;
function check_switches(ok)
	for i=1,7,1 do
	  if error_switch[i] then
	    step=1;
		for i=1,7,1 do
		error_switch[i]=false
		switch[i]=false
		end;
		for i=1001,1007,1 do
			set_pos_in_img(i,0,0,64,112);
		end;
		for i=1032,1038,1 do
			setcolor(i,0.5,0.5,0.5,1);
		 end;
	  return;end;
	  
	  for i=1025,1031,1 do
		speciale_action(4,i)		
		speciale_action(2,i,true);

	  end;
	end; 
	finish_mini_game(true); 
end;

loadresource("data\\btn.png","btn",1001);
loadresource("data\\10\\11\\handles.png","handles",1002);
loadresource("data\\10\\11\\switch.png","switch",1003);
loadresource("data\\10\\11\\first.png","first",1004);

loadresource("data\\10\\11\\red.png","red",1011);
loadresource("data\\10\\11\\orange.png","orange",1012);
loadresource("data\\10\\11\\yellow.png","yellow",1013);
loadresource("data\\10\\11\\green.png","green",1014);
loadresource("data\\10\\11\\blue.png","blue",1015);
loadresource("data\\10\\11\\darkblue.png","darkblue",1016);
loadresource("data\\10\\11\\purple.png","purple",1017);
loadresource("data\\10\\11\\bg1.png","bg1",1018);
loadresource("data\\10\\11\\bg.jpg","bg",1019);

set_activ_free_leaf("mini");


AddSkipBtn(439,577)
addactivobjecttogame(6000,"buttons",118,570,"","",0,0,783,975,34,34);
addactivobjecttogame(1010,"btn",136,100,"","",0,0, 0,105,35,35,0,"1013");
-- addactivobjecttogame(1011,"btn",136,100,"","",0,0, 0,0,35,35,0,"1013");
-- addactivobjecttogame(1012,"btn",136,100,"","",0,0, 0,0,35,35,0,"1013");

addstaticobjecttogame(1001,"handles",147,427,"");
addstaticobjecttogame(1002,"handles",259,427,"");
addstaticobjecttogame(1003,"handles",366,427,"");
addstaticobjecttogame(1004,"handles",477,427,"");
addstaticobjecttogame(1005,"handles",583,427,"");
addstaticobjecttogame(1006,"handles",697,427,"");
addstaticobjecttogame(1007,"handles",807,427,"");

for i=1001,1007,1 do
	set_pos_in_img(i,0,0,64,112);
	speciale_action(10,i)
end;

addactivobjecttogame(1017,"switch",128,381,"","");
addactivobjecttogame(1018,"switch",238,381,"","");
addactivobjecttogame(1019,"switch",345,381,"","");
addactivobjecttogame(1020,"switch",453,381,"","");
addactivobjecttogame(1021,"switch",564,381,"","");
addactivobjecttogame(1022,"switch",674,380,"","");
addactivobjecttogame(1023,"switch",785,380,"","");
addstaticobjecttogame(1024,"bg1",112,85,"");
addstaticobjecttogame(1025,"red",125,117,"");
addstaticobjecttogame(1026,"orange",130,148,"");
addstaticobjecttogame(1027,"yellow",120,164,"");
addstaticobjecttogame(1028,"green",125,193,"");
addstaticobjecttogame(1029,"blue",129,220,"");
addstaticobjecttogame(1030,"darkblue",127,243,"");
addstaticobjecttogame(1031,"purple",114,254,"");

addstaticobjecttogame(1032,"first",132,124,"");
addstaticobjecttogame(1033,"first",132,150,"");
addstaticobjecttogame(1034,"first",132,176,"");
addstaticobjecttogame(1035,"first",132,200,"");
addstaticobjecttogame(1036,"first",132,223,"");
addstaticobjecttogame(1037,"first",132,248,"");

addstaticobjecttogame(1038,"first",132,272,"");
addstaticobjecttogame(1039,"bg",131,87,"",0,0,765,495);

switch={}
for i=1,7,1 do
	switch[i]=false;
end;

error_switch={};
for i=1,7,1 do
error_switch[i]=false;
end;
step=1;

for i=1025,1031,1 do
speciale_action(2,i);
end;

for i=1032,1038,1 do
	setcolor(i,0.5,0.5,0.5,1);
end;

speciale_action(2,1010);
for i=1017,1024,1 do
	speciale_action(2,i);
end;
for i=1032,1039,1 do
	speciale_action(2,i);
end;