
is_error = false;
object = 0;
mouseclick = false;
mission_complete = false;

skip = false;

function SkipActions()
    for i=1011,i,1 do
        if not texture[i] then
            speciale_action(2,i,true,1)
        end;
    end;
    finish_mini_game(true);
    HideHelp()
    set_text(2002,"1012")    
    speciale_action(2,10011)
end;

function mini_create ()
    show_help_wnd=true;
    init_mini(true);
    
    create_mini(8128);
    StartTimer(88821,0.5)
    flags.minipen=true
end;

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

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

    if id == 88850 then      
      Block_Show_Cur(false);
      UnStoreObj(obj.merdn.id);
    return; end;
  return; end;
  
  if sender == 30 then 
    flags.minipen=false
    DeleteResource("notebook_05");
    DeleteResource("notebook_06");
    DeleteResource("notebook_07");
    DeleteResource("notebook");
    DeleteResource("notebook_10");  
    FreeCustomCursor(object);  
    setcurentleaf("laborator",2,0);          
    Block_Show_Cur(false);    
    if flags.mini_notebook then
        UnStoreObj(obj.merdn.id);
        speciale_action(2,17);
        Set_Anim_Cur(17,2);
    AddParticleToObject(17,"p3",308,328);
    MoveEmiter("p3",308,328);
    StartEmiter("p3");          
        to_mir_comics=true
        IfTableClose()
        WaitRender();
    end;
  return; end;
  
  if sender==37 then
    skip = true;
  return;end;
  
  if sender == 10 then    
    playeffect("miniok")
    flags.mini_notebook = true;
    skip=false
    HideHelp()
    set_text(2002,"1012")    
    speciale_action(2,10011)    
    StartTimer(88850,1);
    Block_Show_Cur(true);
  return; end;
 
  if sender==6  then
  if flags.mini_notebook then
      clear_satelite_leaf("laborator");     
     end; 
     mouseclick=false;
  return;end;
  if sender == 1 then

       if attachedID ~= -1 and attachedID~=1006 then
        RemObjFromMouse()
      end;   


    if id == 1006 then
        Set_Anim_Cur(1006,3)
        ClearCursor()
        SetCustomCursor(1006);
        object = id;
    return; end;
  return; end;

  if sender==8128 or sender==5 then
    mouseclick=true;
    if mission_complete then
      mouseclick = false;
    end;
  return;end;
  
  if sender==8129 or sender==6 then
    if mission_complete and not mouseclick then
      StartTimer(88850,0.5);
    return; end;
    mouseclick=false;    
  return;end;      
  if sender == 35 then
    if id >= 1011 and id <= i and object == 1006 and mouseclick then
      count_error = 0;
      speciale_action(2,id);
      StopOnMouseOver(id);
      texture[id] = true;
      playeffect("pencil")
      for j = 1011,i,1 do
        if texture[j] == false then
          count_error = count_error+1;
        end;
      end;
      if count_error<4 then
        finish_mini_game(true);
        FreeCustomCursor(object)
        SetObjectPosition(object,2000,2000)
        object=0
        mission_complete = true;
      return; end;
    return; end;
  return; end;
  
end;

function mini_delete ()

end;
function SheetSwitched(nCount)
end;