center_left_3 =  {"InstantiationOfCircleR",3,513-37,273-37,476,98 , -math.pi/2, -math.pi/6,2,false}; 
center_left_6 =  {"InstantiationOfCircleR",3,513-37,273-37,596,168, -math.pi/6,  math.pi/6,2,false}; 
center_left_11 = {"InstantiationOfCircleR",3,513-37,273-37,595,307,  math.pi/6,  math.pi/2,2,false};
center_left_12 = {"InstantiationOfCircleR",3,513-37,273-37,477,375,  math.pi/2,5*math.pi/6,2,false};
center_left_10 = {"InstantiationOfCircleR",3,513-37,273-37,362,313,5*math.pi/6,7*math.pi/6,2,false};
center_left_5 =  {"InstantiationOfCircleR",3,513-37,273-37,357,167,7*math.pi/6,3*math.pi/2,2,false};

center_right_5  = {"InstantiationOfCircleR",3,513-37,273-37,357,167,7*math.pi/6, 5*math.pi/6,2,false};
center_right_10 = {"InstantiationOfCircleR",3,513-37,273-37,362,313,5*math.pi/6,   math.pi/2,2,false};
center_right_12 = {"InstantiationOfCircleR",3,513-37,273-37,477,375,  math.pi/2,   math.pi/6,2,false};
center_right_11 = {"InstantiationOfCircleR",3,513-37,273-37,595,307,  math.pi/6,  -math.pi/6,2,false};
center_right_6  = {"InstantiationOfCircleR",3,513-37,273-37,596,168, -math.pi/6,  -math.pi/2,2,false};
center_right_3  = {"InstantiationOfCircleR",3,513-37,273-37,476,98 , -math.pi/2,-5*math.pi/6,2,false};

left_up_2  = {"InstantiationOfCircleR",3,393-37,206-37,235,95 ,-5*math.pi/6, -math.pi/2,2,false};
left_up_0  = {"InstantiationOfCircleR",3,393-37,206-37,358,31 ,  -math.pi/2, -math.pi/6,2,false};
left_up_3  = {"InstantiationOfCircleR",3,393-37,206-37,476,98 ,  -math.pi/6,  math.pi/6,2,false};
left_up_8  = {"InstantiationOfCircleR",3,393-37,206-37,476,237,   math.pi/6,  math.pi/2,2,false};
left_up_10 = {"InstantiationOfCircleR",3,393-37,206-37,362,313,   math.pi/2,5*math.pi/6,2,false};
left_up_7  = {"InstantiationOfCircleR",3,393-37,206-37,234,237, 5*math.pi/6,7*math.pi/6,2,false};

left_down_7  = {"InstantiationOfCircleR",3,393-37,206-37,234,237, 5*math.pi/6,   math.pi/2,2,false};
left_down_10 = {"InstantiationOfCircleR",3,393-37,206-37,362,313,   math.pi/2,   math.pi/6,2,false};
left_down_8  = {"InstantiationOfCircleR",3,393-37,206-37,476,237,   math.pi/6,  -math.pi/6,2,false};
left_down_3  = {"InstantiationOfCircleR",3,393-37,206-37,476,98 ,  -math.pi/6,  -math.pi/2,2,false};
left_down_0  = {"InstantiationOfCircleR",3,393-37,206-37,358,31 ,  -math.pi/2,-5*math.pi/6,2,false};
left_down_2  = {"InstantiationOfCircleR",3,393-37,206-37,235,95 ,-5*math.pi/6,-7*math.pi/6,2,false};

right_up_3  = {"InstantiationOfCircleR",3,632-37,206-37,476,98 ,7*math.pi/6, 5*math.pi/6,2,false};
right_up_8  = {"InstantiationOfCircleR",3,632-37,206-37,476,237,5*math.pi/6,   math.pi/2,2,false};
right_up_11 = {"InstantiationOfCircleR",3,632-37,206-37,595,307,  math.pi/2,   math.pi/6,2,false};
right_up_9  = {"InstantiationOfCircleR",3,632-37,206-37,718,242,  math.pi/6,  -math.pi/6,2,false};
right_up_4  = {"InstantiationOfCircleR",3,632-37,206-37,721,103, -math.pi/6,  -math.pi/2,2,false};
right_up_1  = {"InstantiationOfCircleR",3,632-37,206-37,595,32 , -math.pi/2,-5*math.pi/6,2,false};

right_down_1  = {"InstantiationOfCircleR",3,632-37,206-37,595,32 ,  -math.pi/2, -math.pi/6,2,false};
right_down_4  = {"InstantiationOfCircleR",3,632-37,206-37,721,103,  -math.pi/6,  math.pi/6,2,false};
right_down_9  = {"InstantiationOfCircleR",3,632-37,206-37,718,242,   math.pi/6,  math.pi/2,2,false};
right_down_11 = {"InstantiationOfCircleR",3,632-37,206-37,595,307,   math.pi/2,5*math.pi/6,2,false};
right_down_8  = {"InstantiationOfCircleR",3,632-37,206-37,476,237, 5*math.pi/6,7*math.pi/6,2,false};
right_down_3  = {"InstantiationOfCircleR",3,632-37,206-37,476,98 , 7*math.pi/6,3*math.pi/2,2,false};

local object_id = 0;
local press = false;
local count_a = 0; --центр
local count_b = 0; --левый
local count_c = 0; --правый
local result = true;
local fishka1 = 0;
local fishka2 = 0;
local fishka3 = 0;
local fishka4 = 0;

function mini_create ()
    show_help_wnd=true;
    init_mini(1);
    create_mini(33,13,13,
    1011,5000,2,3,-1,         --0
    1006,-1,3,4,-1,           --1
    1015,-1,0,7,-1,           --2
    1007,-1,0,1,5,6,8,-1,     --3
    1016,-1,1,9,-1,           --4
    1008,-1,3,10,-1,          --5
    1012,-1,3,11,-1,          --6
    1017,-1,2,10,-1,          --7
    1009,-1,3,10,11,-1,       --8
    1013,-1,4,11,-1,          --9
    1010,-1,5,7,8,12,-1,      --10
    1018,-1,6,8,9,12,-1,      --11
    1014,-1,10,11,-1,          --12
    358-1,31-1,432+1,106+1,   --0
    595-1,32-1,669+1,107+1,   --1
    235-1,95-1,309+1,170+1,   --2
    476-1,98-1,550+1,173+1,   --3
    721-1,103-1,795+1,178+1,   --4
    357-1,167-1,431+1,242+1,   --5
    596-1,168-1,670+1,243+1,   --6
    234-1,237-1,308+1,312+1,   --7
    476-1,237-1,550+1,312+1,   --8
    718-1,242-1,792+1,317+1,   --9
    362-1,313-1,436+1,388+1,   --10
    595-1,307-1,669+1,382+1,   --11
    477-1,375-1,551+1,450+1,   --12  
    1,1,-1);
    StartTimer(88821,0.5)
end;

function SkipActions()
  HideSkip()
  HideHelp()
      Block_Show_Cur(true);
      playeffect("miniok")
      StartTimer(88850,1.5);
  finish_mini_game(true)

end;
function Buttons_T(sender,id)
   ButtonTreatment(id,10001,10002,10003,CloseBtnX,CloseBtnY,CloseWidth,CloseHeight,sender,"to_another_world",true)
   ButtonTreatment(id,10021,10022,10023,HelpBtnX,HelpBtnY,HelpWidth,HelpHeight,sender,"to_another_world",true,564,200,150)
   if skip then
    ButtonTreatment(id,10011,10012,10013,SkipBtnX,SkipBtnY,111,33,sender,"to_another_world",true)
   end; 
end;
function gameinput (sender,id,attachedID)
CursorTreatment(id,sender,attachedID);
Buttons_T(sender,id)
   
    if sender == 30 then 
    objectid = 0;
        DeleteResource("zamok_in_world05");
        DeleteResource("zamok_in_world"); 
        DeleteResource("zamok_in_world28");           
        setcurentleaf("to_another_world",20,0);     
        Block_Show_Cur(false);
      if flags.zamok_in_world then
        speciale_action(2,7);
        fromzamok=true
        CreatePlashechka(900000,"3052")
        Block_Show_Cur(true);
        WaitRender()
      end;
    return; end;
    
    if sender==10 then
        HideSkip()
        HideHelp()
      Block_Show_Cur(true);
      playeffect("miniok")
      StartTimer(88850,1.5);
    return; end;
    
    
    if sender==37 then
      skip = true;
    return;end;

    if sender == 100 then
      StartTimer(88811,0.3);
    return; end;
    
    if sender == 36 then      
      if id == 8886 then
        Block_Show_Cur(false);
      return; end;
      if id == 88811 then
        Block_Show_Cur(false);
        CreatePlashechka(900000,"564")
      return; end;
      if id == 88850 then    
        Block_Show_Cur(false);
        flags.zamok_in_world = true;       
        clear_satelite_leaf("to_another_world");
        finish_mini_game(true);
      return; end;
    return; end;
    
    if sender==35 then

        if id>=1022 and id<=1027 then
            if not naveli[id] then
                setcolor(id,1,0.2,0.5,1);
                naveli[id]=true
            end;
        end;
    end;

    if sender==39 then
        for i=1022,1027,1 do
            if naveli[i] then
            naveli[i]=false
            setcolor(i,1,1,1,1);
            end;
        end;
    end;    
    
    if sender == 1 then
      if attachedID ~= -1 then
        RemObjFromMouse()
      end;    

      if id == 1022 then --вправо центр круг
        playeffect("krutilki")
        press = true;
        objectid = id;
        speciale_action(2,id);
        count_a = count_a - 60;
        RotateObject(1019,count_a + 60,count_a,2);
        obj1 = gtrGetData(5);
        obj2 = gtrGetData(10);
        obj3 = gtrGetData(12);
        obj4 = gtrGetData(11);
        obj5 = gtrGetData(6);
        obj6 = gtrGetData(3);
        StartTravel(obj1,1,nil,nil,center_right_5);
        StartTravel(obj2,1,nil,nil,center_right_10);
        StartTravel(obj3,1,nil,nil,center_right_12);
        StartTravel(obj4,1,nil,nil,center_right_11);
        StartTravel(obj5,1,nil,nil,center_right_6);
        StartTravel(obj6,1,nil,nil,center_right_3);
        result = gtrShift(6,{5,10,12,11,6,3});
      return; end;
      if id == 1023 then --влево центр круг
        playeffect("krutilki")
        press = true;
        objectid = id;
        speciale_action(2,id);
        count_a = count_a + 60;
        RotateObject(1019,count_a - 60,count_a,2);
        obj1 = gtrGetData(3);
        obj2 = gtrGetData(6);
        obj3 = gtrGetData(11);
        obj4 = gtrGetData(12);
        obj5 = gtrGetData(10);
        obj6 = gtrGetData(5);
        StartTravel(obj1,1,nil,nil,center_left_3);
        StartTravel(obj2,1,nil,nil,center_left_6);
        StartTravel(obj3,1,nil,nil,center_left_11);
        StartTravel(obj4,1,nil,nil,center_left_12);
        StartTravel(obj5,1,nil,nil,center_left_10);
        StartTravel(obj6,1,nil,nil,center_left_5);
        result = gtrShift(6,{3,6,11,12,10,5});
      return; end;
      if id == 1024 then --вверх левый круг
        playeffect("krutilki")
        press = true;
        objectid = id;
        speciale_action(2,id);
        count_b = count_b+60;
        RotateObject(1021,count_b-60,count_b,2);
        obj1 = gtrGetData(2);
        obj2 = gtrGetData(0);
        obj3 = gtrGetData(3);
        obj4 = gtrGetData(8);
        obj5 = gtrGetData(10);
        obj6 = gtrGetData(7);
        StartTravel(obj1,1,nil,nil,left_up_2);
        StartTravel(obj2,1,nil,nil,left_up_0);
        StartTravel(obj3,1,nil,nil,left_up_3);
        StartTravel(obj4,1,nil,nil,left_up_8);
        StartTravel(obj5,1,nil,nil,left_up_10);
        StartTravel(obj6,1,nil,nil,left_up_7);
        result = gtrShift(6,{2,0,3,8,10,7});
      return; end;
      if id == 1025 then --низ левый круг
        playeffect("krutilki")
        press = true;
        objectid = id;
        speciale_action(2,id);
        count_b = count_b-60;
        RotateObject(1021,count_b+60,count_b,2);        
        obj1 = gtrGetData(7);
        obj2 = gtrGetData(10);
        obj3 = gtrGetData(8);
        obj4 = gtrGetData(3);
        obj5 = gtrGetData(0);
        obj6 = gtrGetData(2);
        StartTravel(obj1,1,nil,nil,left_down_7);
        StartTravel(obj2,1,nil,nil,left_down_10);
        StartTravel(obj3,1,nil,nil,left_down_8);
        StartTravel(obj4,1,nil,nil,left_down_3);
        StartTravel(obj5,1,nil,nil,left_down_0);
        StartTravel(obj6,1,nil,nil,left_down_2);
        result = gtrShift(6,{7,10,8,3,0,2});
      return; end;
      if id == 1026 then --вверх правый
        playeffect("krutilki")
        press = true;
        objectid = id;
        speciale_action(2,id);
        count_c = count_c-60;
        RotateObject(1020,count_c+60,count_c,2);        
        obj1 = gtrGetData(3);
        obj2 = gtrGetData(8);
        obj3 = gtrGetData(11);
        obj4 = gtrGetData(9);
        obj5 = gtrGetData(4);
        obj6 = gtrGetData(1);        
        StartTravel(obj1,1,nil,nil,right_up_3);
        StartTravel(obj2,1,nil,nil,right_up_8);
        StartTravel(obj3,1,nil,nil,right_up_11);
        StartTravel(obj4,1,nil,nil,right_up_9);
        StartTravel(obj5,1,nil,nil,right_up_4);
        StartTravel(obj6,1,nil,nil,right_up_1);
        result = gtrShift(6,{3,8,11,9,4,1});
      return; end;
      if id == 1027 then --вниз правый
        playeffect("krutilki")
        press = true;
        objectid = id;
        speciale_action(2,id);
        count_c = count_c+60;
        RotateObject(1020,count_c-60,count_c,2);        
        obj1 = gtrGetData(1);
        obj2 = gtrGetData(4);
        obj3 = gtrGetData(9);
        obj4 = gtrGetData(11);
        obj5 = gtrGetData(8);
        obj6 = gtrGetData(3);
        StartTravel(obj1,1,nil,nil,right_down_1);
        StartTravel(obj2,1,nil,nil,right_down_4);
        StartTravel(obj3,1,nil,nil,right_down_9);
        StartTravel(obj4,1,nil,nil,right_down_11);
        StartTravel(obj5,1,nil,nil,right_down_8);
        StartTravel(obj6,1,nil,nil,right_down_3);
        result = gtrShift(6,{1,4,9,11,8,3});
      return; end;
    return; end;
    
    if sender == 6 and press then
        Block_Show_Cur(true);
        speciale_action(2,objectid);
        press = false;        
        StartTimer(8886,2);
    return; end;    
    
    if sender == 7 then
      fishka1 = gtrGetData(3);
      fishka2 = gtrGetData(8);
      fishka3 = gtrGetData(10);
      fishka4 = gtrGetData(11);
      if (fishka1 == 1011 or fishka1 == 1012 or fishka1 == 1013 or fishka1 == 1014) and (fishka2 == 1011 or fishka2 == 1012 or fishka2 == 1013 or fishka2 == 1014) and (fishka3 == 1011 or fishka3 == 1012 or fishka3 == 1013 or fishka3 == 1014) and (fishka4 == 1011 or fishka4 == 1012 or fishka4 == 1013 or fishka4 == 1014) then
        Block_Show_Cur(true);
        StartTimer(88850,1.5);
      return; end;
    return; end;

end;
