-- if not flags.load_comics6 and not flags.starting_comics6 then
  -- flags.starting_comics6 = true;
  -- thread_comics6 = PreLoadResource("./data/0/global_res.lua","comics6","finish_preload_comics");
-- end;

local objectid = 0;
local count = 0;
local kontakt = false;

skip = false;
function mini_create ()
    show_help_wnd=true;
    init_mini(true);
    
    create_mini(8128);
    StartTimer(88821,0.5)
end;

function SkipActions()
    if not flags.obj1017 then
        speciale_action(2,1007,true);
        setcolor(1017,1,1,1,1);    
        speciale_action(2,1017,true);
    end;
    if not flags.obj1016 then
        speciale_action(2,1008,true);
        setcolor(1016,1,1,1,1);        
        speciale_action(2,1016,true);
    end;
    if not flags.obj1015 then
        speciale_action(2,1014,true);
        setcolor(1015,1,1,1,1);        
        speciale_action(2,1015,true);
    end;
    if not flags.obj1013 then
        speciale_action(2,1012,true);
        setcolor(1013,1,1,1,1);        
        speciale_action(2,1013,true);    
    end;
    flags.obj1015=true
    flags.obj1013=true
    flags.obj1016=true
    flags.obj1017=true    
    skip=false
    HideSkip()
    HideHelp()
    --finish_mini_game(true)
end;

function Buttons_T(sender,id)
   ButtonTreatment(id,10001,10002,10003,CloseBtnX,CloseBtnY,CloseWidth,CloseHeight,sender,"parom_main",true)
   ButtonTreatment(id,10021,10022,10023,HelpBtnX,HelpBtnY,HelpWidth,HelpHeight,sender,"parom_main",true,317,200,150)
   if skip then
    ButtonTreatment(id,10011,10012,10013,SkipBtnX,SkipBtnY,111,31,sender,"parom_main",true)
   end;  
end; 

function gameinput (sender,id,attachedID)
 CursorTreatment(id,sender,attachedID); 
    Buttons_T(sender,id)  
 
  if sender == 100 then
    Block_Show_Cur(false); 
    StartTimer(88811,0.3);
  return; end;
  

  
  if sender == 36 then  
   
    if id == 88811 then
    Block_Show_Cur(false);    
    if not (flags.obj1015 and flags.obj1013 and flags.obj1016 and flags.obj1017) then
      
      CreatePlashechka(900000,"317")
      end;
    return; end;
    if id == 88850 then    
--      Block_Show_Cur(false);    
        UnStoreObj(obj.knstro.id);
        Block_Show_Cur(true);
        -- speciale_action(2,1006,true);
        -- speciale_action(2,1010,true);
        --StartTimer(88850,1);      
      --clear_satelite_leaf("parom_main");
          HideSkip()
        HideHelp()
        finish_mini_game(true);     
        clear_satelite_leaf("parom_main");      
    return; end;

  return; end;
  
  if sender == 30 then 
    objectid = 0;
    DeleteResource("motor05");
    DeleteResource("motor_big1");
    DeleteResource("motor_big2");    
    DeleteResource("motor18");    
    DeleteResource("kanistra");   
    setcurentleaf("parom_main",10,0);
    DarkScreen(false); 
    Block_Show_Cur(false);    
    if flags.motor then
      CreatePlashechka(900000,"3053")
      ActivateObject(9,false);
      Set_Anim_Cur(9,3);
      StopEmiter("jama")
      speciale_action(2,20);
      Set_Anim_Cur(20,14);
      AddParticleToObject(20,"perehod",166,138);
      MoveEmiter("perehod",166,138);
      StartEmiter("perehod");       
    return; end;
  return; end;
  
  if sender==37 then
    skip = true;
  return;end;
  
  if sender == 10 then    
   

    
  return; end;
 

 
  if sender==16 then
      if id==1030 then
        speciale_action(2,1030,true,2)
        playeffect("benzin")
        speciale_action(2,1031,true,2)
      return;end;
      if id==1031 then
        speciale_action(2,1031,true,2)

      return;end;      
  return;end;
 if sender==15 then
 if id==1031 then
         speciale_action(2,1006,true,2);
        speciale_action(2,1010,true,2);
        StartTimer(88850,3);
 end;
 return;end;
  if sender == 1 then
  

    if id == 1007 or id == 1008 or id == 1012 or id == 1014 then -- клик на запчасть
        if attachedID ~= -1 then
        RemObjFromMouse()
      end;      
    setcolor(1007,1,1,1,1);
    setcolor(1008,1,1,1,1);
    setcolor(1012,1,1,1,1);
    setcolor(1014,1,1,1,1);    
  
    objectid = id;
    Set_Anim_Cur(id,3)
    setcolor(id,0.5,0.5,0,1);
    return; end;
    if id == 1011 then
        if  flags.obj1015 and flags.obj1013 and flags.obj1016 and flags.obj1017 then
            if obj.knstro ~= nil and attachedID == obj.knstro.id then
                RemObjFromMouse()
                UnStoreObj(attachedID);
                Block_Show_Cur(true);
                 flags.motor = true;
                speciale_action(2,1030,true,2);
            return; end;
            if attachedID~=-1 and ((obj.knstro~=nil and attachedID ~= obj.knstro.id) or (obj.knstro==nil ))  then
                RemObjFromMouse() 
                CreatePlashechka(900000,"1001")
            return;end;        
            CreatePlashechka(900000,"3027")      
        return; end;    
    if obj.knstro ~= nil and attachedID == obj.knstro.id then    
        CreatePlashechka(900000,"3028")     
    return; end;
    if attachedID~=-1 and ((obj.knstro~=nil and attachedID ~= obj.knstro.id) or (obj.knstro==nil ))  then
        RemObjFromMouse() 
        CreatePlashechka(900000,"1001")
    return;end;        
    CreatePlashechka(900000,"3027")          
    return; end;
    
    if id==1021 then
        if objectid==1007 then
            count = count + 1;
            playeffect("statuetka")
            speciale_action(2,objectid,true);
            setcolor(1017,1,1,1,1);
            if not naveli17 then
            speciale_action(2,1017,true);
            end;
            flags.obj1017=true            
            Set_Anim_Cur(1021,3)
            StopOnMouseOver(1021)
            ActivateObject(1021,false);
            objectid=0
            if flags.obj1015 and flags.obj1013 and flags.obj1016 and flags.obj1017  then
            CreatePlashechka(900000,"319")
            skip=false
            HideSkip()
            HideHelp()
            return; end;        
        return; end;
        if objectid~=0 then
        CreatePlashechka(900000,"318")
        return; end;
        Set_Anim_Cur(objectid,4)
        CreatePlashechka(900000,"1006")
    return; end;
    
    if id==1022 then
        if objectid == 1008 then
            kontakt = true;
            count = count + 1;
            playeffect("probka")
            speciale_action(2,objectid,true);
            setcolor(1016,1,1,1,1);
            if not naveli16 then
            speciale_action(2,1016,true);
            end;
            flags.obj1016=true
            objectid=0
            if flags.obj1015 and flags.obj1013 and flags.obj1016 and flags.obj1017  then
            CreatePlashechka(900000,"319")
            skip=false
            HideSkip()
            HideHelp()
            return; end;            
        return; end;    
        if objectid == 1014 and flags.obj1016 then
            count = count + 1;
            playeffect("statuetka")
            speciale_action(2,objectid,true);
            setcolor(1015,1,1,1,1);
            if not naveli15 then
            speciale_action(2,1015,true);
            end;
            Set_Anim_Cur(1022,3)
            StopOnMouseOver(1022)
            ActivateObject(1022,false);                
            flags.obj1015=true
            objectid=0
                if flags.obj1015 and flags.obj1013 and flags.obj1016 and flags.obj1017  then
                CreatePlashechka(900000,"319")
                skip=false
                HideSkip()
                HideHelp()
                return; end;
        return;end;
        if objectid~=0 then
        CreatePlashechka(900000,"318")
        return; end;
        CreatePlashechka(900000,"1006")
        Set_Anim_Cur(objectid,4)
  return; end;
  
  if id==1020 then
      if objectid == 1012 then
        count = count + 1;
        playeffect("shlang")
        speciale_action(2,objectid,true);
        setcolor(1013,1,1,1,1);
        if not naveli13 then
        speciale_action(2,1013,true);
        end;
        flags.obj1013=true
            Set_Anim_Cur(1020,3)
            StopOnMouseOver(1020)
            ActivateObject(1020,false);    
        objectid=0        
        if flags.obj1015 and flags.obj1013 and flags.obj1016 and flags.obj1017  then
        CreatePlashechka(900000,"319")
        skip=false
        HideSkip()
        HideHelp()
        return; end;
      return; end;
        if objectid~=0 then
        CreatePlashechka(900000,"318")
        return; end;
        Set_Anim_Cur(objectid,4)
        CreatePlashechka(900000,"1006")
  return;end;
  
  return; end;
 
  if sender==35 then
    if id==1020 and objectid == 1012 then
        speciale_action(2,1013);
        naveli13=true;
    return;end;
    if id==1021 and objectid == 1007 then
        speciale_action(2,1017);
        naveli17=true
    return;end;
    if id==1022 then
        if objectid == 1008 then
            speciale_action(2,1016);    
            naveli16=true;
        return;end;    
        if objectid == 1014 and flags.obj1016 then
            speciale_action(2,1015);    
            naveli15=true;    
        return;end;        
    return;end;    
  return;end;

  if sender==39 then
    if naveli13 and not flags.obj1013 then
        speciale_action(2,1013);
        naveli13=false;
    return;end;
    if naveli17 and not flags.obj1017 then
        speciale_action(2,1017);
        naveli17=false
    return;end;
    if naveli16 and not flags.obj1016 then
        speciale_action(2,1016);    
        naveli16=false;
    return;end;    
    if naveli15 and not flags.obj1015 then
        speciale_action(2,1015);    
        naveli15=false;    
    return;end;        
  return;end;
  
end;

function mini_delete ()

end;
function SheetSwitched(nCount)
end;