function Timer(ncount, Param1)
     if not StopSheet then
          AlfingSheet();
          StopSheet=false;
     return;end;
return;end;
function mau()
     playeffect("mau");
return;end;
function SheetSwitched (ncount)
     StopSheet=true;
return;end;
function gameinput (sender,obj_id,attachedID)

  if sender==12 then
  if SLevel==1.0 then return;end;
      if obj_id ==106 then
      AddElement("gr",106);
      setcolor(106,0,0,0,0.5,1);
      StopEmiter("pu4ok2"); 
      MoveObjectToTree(106); 
      playeffect("29");
    flags.match=true;
    return; end;
    if obj_id ==105 then
      AddElement("gr",105);
      SetAlfaSheet(2.5)
      setcolor(105,0,0,0,0.5,1);
      MoveObjectToTree(105); 
  end;
    if obj_id ==221 then
        AddElement("gr",obj_id);
        SetAlfaSheet(2.5)
        setcolor(obj_id,0,0,0,0.5,1);
        MoveObjectToTree(obj_id); 
    end;
    if obj_id ==111 then
        AddElement("gr",obj_id);
        SetAlfaSheet(2.5)
        setcolor(obj_id,0,0,0,0.5,1);
        MoveObjectToTree(obj_id);  
        flags.flowerpot=true;
        CreateWindow(150,250,"2111",nil,nil,250,30); 
  end;
    if flags.loc3 then
      if flags.loc1 and flags.loc2 and flags.loc3 then
      flags.loc3=false;
        ShowMenu(false)
        flags.levelcomplete=true;
        DarkScreen(true);
        ShowMenu(false)
      return; end;  
      CreateWindow(150,250,"199",nil,nil,250,30);
        --playeffect("01");  
    return;end;



  return;end;
  if sender == 2 then
      RemoveFromMouse(object);
    MessageProc(sender,obj_id);
  return;end;
if sender==33 then
    BlockCursor(false);
    if obj_id==501 then -- тёмная плашка
      BlockCursor(false);
      if whole_darkness then
         if flags.levelcomplete then
          SetAlfa(500,0,1,1);
          speciale_action(4,500);
          BlockCursor(true);

        return;end;      
         --затемнилось
      return;end;
      whole_darkness=false;
         -- растемнилось

        AddParticleToObject(69,"patron",714,91);
        MoveEmiter("patron",714,91);
        if not ligth then
          StartEmiter("patron"); 
        end;
      ShowMenu(true);
    return;end;

  return;end
    if pause_state then
    if sender==1 or sender==6 or sender==14 then
      pause_state=false;
      --set_visible_object(11111,false);
    end;  
  return;end;
if sender == 1 then --кликнули левой кнопкой мыши на активный объект  

      if obj_id==501 then
        if flags.levelcomplete then
          LoadNextLevel()
        return;end;        
            DarkScreen(false);
            whole_darkness=false;
          SetAlfa(503,1,0,1);
      return;end;
        if obj_id==68  then
  if attachedID ==-1 then
     setcurentleaf("barton_zal",1,1);
     playeffect("door");  
      SwitchToSheet("re");
  return; end;  
  return; end;
  if not flags.light then
  
  if obj_id==69 then
    if attachedID==104 then-- заменить 
    playeffect("17");  
        flags.light = true;    
        RemoveFromMouse(attachedID);
        DeleteElement("gr",attachedID);  
        SetAlfaSheet(2.0)
        Set_Cursor(69,3);
        speciale_action(2,4);
        CreateWindow(150,250,"211",nil,nil,250,30); 
          --playeffect("01");  
        StopEmiter("patron"); 
        AddParticleToObject(105,"babo4ka",110,460);
        MoveEmiter("babo4ka",110,460);
          StartEmiter("babo4ka");

         setcurentleaf("barton_vhod",1,0);
        Set_Cursor(45,2);
        AddParticleToObject(45,"Svet14",225,361);
        MoveEmiter("Svet14",225,361);
        if not flags.minicomplete35 then
          StartEmiter("Svet14"); 
        end;

     end;
    if attachedID~=104 and attachedID>-1 then-- заменить 
        RemoveFromMouse(attachedID);
         CreateWindow(150,250,"200",nil,nil,250,30);   
  --playeffect("01");           
    return; end;
    if attachedID ==-1 then    
      CreateWindow(150,250,"212",nil,nil,250,30);  
  --playeffect("01");        
    return; end;
    setcurentleaf("oranjereya",1,2);
  return; end;  
    CreateWindow(150,250,"210",nil,nil,250,30);    
      --playeffect("01");  
  return;end;


  if flags.light then
  
  if not flags.minicomplete35 then
    CreateWindow(150,250,"211",nil,nil,250,30);  
      --playeffect("01");  
  return;end;
    
  

      if obj_id==105 then
        if attachedID==221 then-- заменить 
        playeffect("6");  
        flags.babo4ka= true;
          RemoveFromMouse(attachedID);
          SetAlfaSheet(2.0)
          DeleteElement("gr",attachedID);
          collaps_obj(105,0,0,10,0);
          playeffect("20");

          StopEmiter("babo4ka");          
        return; end;
        if attachedID~=221 and attachedID>-1 then-- заменить 
        RemoveFromMouse(attachedID);
          CreateWindow(150,250,"200",nil,nil,250,30);   
          --playeffect("01");            
        return; end;
        if attachedID ==-1 then    
          CreateWindow(150,250,"213",nil,nil,250,30);  
  --playeffect("01");            
        return; end;
      return; end;    
      
    if   attachedID==-1 then
  
      if obj_id==221 then
        collaps_obj(obj_id,0,0,10,0);
        playeffect("20");
      return; end;  
      
      if obj_id==111 then
        collaps_obj(obj_id,0,0,10,0);
        playeffect("20");
      return; end;    
      
      if obj_id==54 then 
      if (not flags.minicomplete15)  then-- мини-игра стекло  
        playeffect("29");      
        add_free_leaf("Root","mini15",0,25);-- Добавляет чистый лист
        set_satelite_leaf("oranjereya");
        DoFile(0,25)
        mini_create();
        flags.nohints=true;
      return; end;
      return; end;
      if obj_id > 0 and obj_id < 200 then --кликаем на активный объект
      -- if not flags.light then
        playeffect("20");
            collaps_obj(obj_id,0,0,10,1);
          return 0; end
      
    return; end;  
  return; end;
  return; end;
    if sender==6 then
    if not flags.posvetlelo then
    if not flags.light then
    RemoveFromMouse(object);
      CreateWindow(150,250,"210",nil,nil,250,30)
        --playeffect("01");  
    return; end;  
    RemoveFromMouse(object);
      CreateWindow(150,250,"211",nil,nil,250,30)
      --playeffect("01");
    return; end;  
  return;end;   
          if sender==36 then          
          if obj_id==9999 then
               if not StopSheet then
                    AlfingSheet();
                    StopSheet=false;
               return;end;
          return;end;                    
     return;end;
  if sender==14 then
      StopSheet=true;
      object=obj_id
    if obj_id>0 then
      addObjectToMouse(obj_id);
    return; end;
  return; end;

      -------------------------------------------На сцене отработали все объекты-------------------------
  if sender==4 then
  -- WriteToConsole("sender = 4, lev1.2".." "..sender.."\n")
  if SLevel==1.0 then return;end;
    flags.loc3 = true;
    
  return; end;
--------------------------------------------------------------------------------------------------------------  
  

end
function SelectRandom()
if not flags.light then
  selectrandomobject(1.5,69);
 end;
if flags.light and  not flags.dver then
  selectrandomobject(1.5,68);
end;
  idObject=GetRandomObject();
if not flags.minicomplete15 and idObject==106 then
selectrandomobject(1.5,54);
 end;
  if flags.loc3  and (not flags.loc2) then
    selectrandomobject(1.5,68);
   end;  
   if flags.loc3  and (not flags.loc1) then
    selectrandomobject(1.5,68);
   end;
  selectrandomobject(1.5,idObject);
end;
function SelectRandomRadar(idObject)
    if idObject==106 then
      selectrandomobject(1.5,54);
  return;end;
  selectrandomobject(1.5,idObject);
end;
