local rest = false;
objectid = 0;


function SkipActions()
    finish_mini_game(true);
end;

function mini_create ()
    show_help_wnd=true;
    if not flags.load_comics7 and not flags.starting_comics7 then
      flags.starting_comics7 = true;
      neighbors.comics7.lock=false;
      LoadLocation("comics7");      
    end;    
    init_mini(1);
  create_mini(33,9,9,
        1017,1023,1,3,-1,
        1019,1022,0,2,4,-1,
        1018,1021,1,5,-1,
        1016,1020,0,4,6,-1,
        1023,1019,1,3,5,7,-1,
        1022,1018,2,4,8,-1,
        1020,1017,3,7,-1,
        1021,1016,4,6,8,-1,
        -1,-1,5,7,-1,
        187+19,261+36,257+19,381+36,
        257+19,261+36,327+19,381+36,
        327+19,261+36,397+19,381+36,
        397+19,261+36,467+19,381+36,
        467+19,261+36,537+19,381+36,
        537+19,261+36,607+19,381+36,
        607+19,261+36,677+19,381+36,
        677+19,261+36,747+19,381+36,
        747+19,261+36,817+19,381+36,
        2,2,-1);
        StartTimer(88821,0.5)
end;
function Buttons_T(sender,id)
   ButtonTreatment(id,10001,10002,10003,CloseBtnX,CloseBtnY,CloseWidth,CloseHeight,sender,"vhod_turmy",true)
   ButtonTreatment(id,10021,10022,10023,HelpBtnX,HelpBtnY,HelpWidth,HelpHeight,sender,"vhod_turmy",true,342,200,150)
   if skip then
    ButtonTreatment(id,10011,10012,10013,SkipBtnX,SkipBtnY,111,31,sender,"vhod_turmy",true)
   end;  
end;
function gameinput (sender,id,attachedID)
CursorTreatment(id,sender,attachedID);
Buttons_T(sender,id)  
   
    if sender == 30 then 
    objectid=0
        DeleteResource("zamok_turmy05");
        DeleteResource("zamok_turmy");
        DeleteResource("zamok_turmy28");           
      setcurentleaf("vhod_turmy",13,0);         
      DarkScreen(false); 
      Block_Show_Cur(false);
      if flags.turma_zamok then
        neighbors.jmp_turma.lock=false;      
        LoadLocation("jmp_turma");    
        speciale_action(2,4);
        CreatePlashechka(900000,"3046")
          speciale_action(2,19);
          speciale_action(2,19,true,3.2);
          speciale_action(2,17,true,3.4);        
        speciale_action(2,5);
        speciale_action(2,11);
        Set_Anim_Cur(11,16);
        StopEmiter("zamok_turmy");
        speciale_action(2,6)
        Set_Anim_Cur(6,2);
        playeffect("gate");
        AddParticleToObject(6,"kusty",785,415);
        MoveEmiter("kusty",785,415);
        StartEmiter("kusty");
        speciale_action(2,7)
        Set_Anim_Cur(7,2);
        AddParticleToObject(7,"generator",632,403);
        MoveEmiter("generator",632,403);
        StartEmiter("generator");
      end;      
    return; end;

  if sender==35
    then
    if not flags.minikeys3_complete then
      iIndex1,iIndex2=gtrGetEmptyNeighbours(1);
      InfoFromGraphTravel(iIndex2);
    end;
    return; end;
  if sender==39
    then
      if not flags.minikeys3_complete then
        InfoFromGraphTravel(-1);
      end;
      return;
    end;

    
    if sender==10 then
        HideSkip()
        HideHelp()
      flags.minikeys3_complete=true;
      playeffect("miniok");
      speciale_action(2,1024,true);
      speciale_action(2,1025,true);
      speciale_action(2,1026,true);
      speciale_action(2,1027,true);
    return; end;
    
    if sender == 16 then
      if id == 1026 then
        Block_Show_Cur(true);
        StartTimer(88850,1);
      return; end;
    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 == 88821 then
      
    return; end;      
      if id == 88811 then
        Block_Show_Cur(false);
        CreatePlashechka(900000,"342")
      return; end;
      if id == 88850 then    
        Block_Show_Cur(false);
        flags.turma_zamok = true;
        clear_satelite_leaf("vhod_turmy");
        finish_mini_game(true);
      return; end;
    return; end;
    
    if sender == 1 then
        if podsv then 
            podsv=false;
            speciale_action(2,1030)
        end;
    
      if attachedID ~= -1 then
        RemObjFromMouse()
      end;
      
   
      if id >= 1016 and id <= 1023  then
        fGame=true;
        add_to_mouse(id);
        objectid=id;
      return; end;
      if id == 1007 then        
        check_mini_game_GraphTravel(-1);
        speciale_action(2,1007);
        rest = true;
      return; end;
    return; end;
    
    if sender==6 then
      if fGame == true and objectid ~= 0 then
        playeffect("keyins");
        RemoveFromMouse(objectid);          
        check_mini_game_GraphTravel(objectid);
        fGame=false;
        objectid=0;
      return; end;    
      if rest then
        speciale_action(2,1007);
        rest = false;
      return; end;
    return; end;    

end;
function GraphTravelReset(nCount)
  SetObjectPosition(1016,400+19,263+36);
  SetObjectPosition(1017,190+19,263+36);
  SetObjectPosition(1018,330+19,263+36);
  SetObjectPosition(1019,260+19,263+36);
  SetObjectPosition(1020,610+19,263+36);
  SetObjectPosition(1021,680+19,263+36);
  SetObjectPosition(1022,540+19,263+36);
  SetObjectPosition(1023,470+19,263+36);
end;

function InfoFromGraphTravel(Param2)

    if Param2~=-1 and lastplawka~=Param2 then
        SetObjectPosition(1030,Fields[Param2+1]+30,261+28*2)
        if not podsv then
        speciale_action(2,1030)
        podsv =true;
        return; end;
        lastplawka=Param2;
        return;
    end;
    if Param2==-1 then
        if podsv then
        speciale_action(2,1030)
        podsv= false;
        return; end;
        lastplawka=-1;
    end;
end;