local maslo = false;

function Buttons_T(sender,obj_id)
    ButtonTreatment(obj_id,10001,10002,10003,CloseBtnX,CloseBtnY,34,34,sender,"parom_main",false)
end; 


function gameinput (sender,obj_id,attachedID)    
 Buttons_T(sender,obj_id)
CursorTreatment(obj_id,sender,attachedID);     
  if sender == 30 then
      DeleteResource("auto2");
      DeleteResource("auto_big");    
      DeleteResource("auto8");     
    DarkScreen(false);
    Block_Show_Cur(false);
    if flags.auto then
        setcurentleaf("parom_main",10,0);
        fromkoleso=true;    
        
        WaitRender()            
    return;end        
    setcurentleaf("parom_main",10,0);
    if flags.is_coleso and not flags.first_auto_visible then
      speciale_action(2,8);
      speciale_action(2,7);
      speciale_action(2,18);
      speciale_action(2,19);
      Set_Anim_Cur(19,2);
      StopEmiter("vepr");
      AddParticleToObject(19,"ugon_auto",574,189);
      MoveEmiter("ugon_auto",574,189);
      StartEmiter("ugon_auto");
      flags.first_auto_visible = true;
    end;

    
  return;end;
  
  if sender == 1 then

    if obj_id == 7 then
      if obj.koleso ~= nil and attachedID == obj.koleso.id then
        RemObjFromMouse()
        UnStoreObj(attachedID);
        flags.is_coleso = true;        
        Set_Anim_Cur(7,3)    
        speciale_action(2,6,true);
        speciale_action(2,5,true);
        speciale_action(2,7,true);
        Set_Anim_Cur(5,4)    
      return; end;
      if attachedID~=-1 and ((obj.koleso~=nil and attachedID ~= obj.koleso.id) or (obj.koleso==nil ))  then
        RemObjFromMouse() 
        CreatePlashechka(900000,"1000")
      return;end;
      
    CreatePlashechka(900000,"299")      
    return; end;
    if obj_id == 5 then
      if obj.bolts ~= nil and attachedID == obj.bolts.id then
        RemObjFromMouse()
        UnStoreObj(attachedID);
        flags.is_bolts = true;
        playeffect("bolts")
        Set_Anim_Cur(5,3)            
        speciale_action(2,4,true);
        speciale_action(2,41,true);
        speciale_action(2,42,true);
        speciale_action(2,5,true);
        Set_Anim_Cur(4,4)    
        Set_Anim_Cur(41,4)    
        Set_Anim_Cur(42,4)    
      return; end;
      if attachedID~=-1 and ((obj.bolts~=nil and attachedID ~= obj.bolts.id) or (obj.bolts==nil ))  then
        RemObjFromMouse()
        CreatePlashechka(900000,"1000")
      return;end;        
    CreatePlashechka(900000,"312")      
    return; end;
    if obj_id == 4 or obj_id == 41 or obj_id == 42 then
      if obj.balkey ~= nil and attachedID == obj.balkey.id then
        ActivateObject(obj_id,false)
        x,y=GetObjectPosition(obj_id);
        SetObjectPosition(20,x-sdv3x,y-sdv3y)
        SetObjectPosition(21,x-sdv2x,y-sdv2y)
        SetObjectPosition(22,x-sdv1x,y-sdv1y)
        obj_g=obj_id
        speciale_action(2,20,true,2)
        Block_Show_Cur(true)
      return; end;
      if attachedID~=-1 and ((obj.balkey~=nil and attachedID ~= obj.balkey.id) or (obj.balkey==nil ))  then
        RemObjFromMouse()
        CreatePlashechka(900000,"1000")
      return;end;    
        CreatePlashechka(900000,"313")      
    return; end;
  return ;end;
  
  if sender == 16 then
    if obj_id==20 or obj_id==21 then
        speciale_action(2,obj_id,true,2)
        speciale_action(2,obj_id+1,true,2)
    return;end;
    if obj_id==22 then
        Block_Show_Cur(false)
        speciale_action(2,obj_id,true,2)
        speciale_action(2,obj_g,true,2)
        count_act=count_act+1;
        if obj_g~=4 then
        Set_Anim_Cur(obj_g,3)        
        speciale_action(2,obj_g,true);
        speciale_action(2,obj_g-10,true);        
        else 
        Set_Anim_Cur(4,3)    
        speciale_action(2,3,true);
        speciale_action(2,4,true);
        end;
        playeffect("zajbolt")
        if count_act==3 then
            RemObjFromMouse()
            UnStoreObj(attachedID);
            Block_Show_Cur(true);
            StartTimer(8882,1);
            flags.auto = true;
         end;        
    return;end;
  return; end;
  
  if sender == 100 then

  return; end;
  
  if sender == 36 then

    if obj_id == 8882 then    
      StartTimer(88850,0.6);
    return; end;
    if obj_id==88850 then
      Block_Show_Cur(false);
      UnStoreObj(obj.koleso.id);
      UnStoreObj(obj.bolts.id);
      UnStoreObj(obj.balkey.id);
      flags.auto = true; 
      clear_satelite_leaf("parom_main");        
    return;end;
  return; end;
 
end
function SheetSwitched(nCount)
end;