function Timer(ncount, Param1)
     if not StopSheet then
          AlfingSheet();
          StopSheet=false;
     return;end;
return;end;
function SheetSwitched (ncount)
     StopSheet=true;
return;end;
function gameinput (sender,obj_id,attachedID)
    if sender == 100 then
  if flags.comx then
    speciale_action(2,12121,true);
    add_free_leaf("map15",14,101);
    set_satelite_leaf("flower");
    DoFile(14,101)
    flags.comx= false;
    flags.comx1= true;
  return;end;
  return;end;
  if sender == 2 then
      RemoveFromMouse(object);
    MessageProc(sender,obj_id);
  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==12 then
      if obj_id==40 then
        AddElement("gr",obj_id);
      SetAlfaSheet(2.5)
      setcolor(obj_id,0,0,0,0.5,1);
      Set_Cursor(40,3);
      MoveObjectToTree(obj_id);
    end;  
    if obj_id==41 then
      AddElement("gr",obj_id);
      SetAlfaSheet(2.5)
      setcolor(obj_id,0,0,0,0.5,1);
      MoveObjectToTree(obj_id);
    end;  
    if obj_id==37 then
      AddElement("gr",obj_id);
      SetAlfaSheet(2.5)
      setcolor(obj_id,0,0,0,0.5,1);
      MoveObjectToTree(obj_id);
    end;
    if flags.all then
      if flags.minicomplete42 then
        flags.all= false;
        flags.levelcomplete=true;
        DarkScreen(true);
        ShowMenu(false)
      return; end;    
    return;end;

  return;end;  
  if sender==35 then
    if obj_id==471 then
      StartAnimation(471,0,6)    
    return;end;
  return;end;
  if sender==26 then
    if obj_id==14 and flags.minicomplete42 then
      if flags.all then
        flags.levelcomplete=true;
        DarkScreen(true);
        ShowMenu(false)
      return;end;
    return; end;
  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(32,"zvezd",154,390);
      MoveEmiter("zvezd",154,390);
      if not flags.rasp then
        StartEmiter("zvezd");
      end;
      AddParticleToObject(33,"cvetok",143,440);
      MoveEmiter("cvetok",143,440);
      if (not flags.minicomplete26) then
        StartEmiter("cvetok");
      end;  
      AddParticleToObject(56,"kran",812,387);
      MoveEmiter("kran",812,387);
      if (not flags.first) then
        StartEmiter("kran");
      end;
      savegame(SaveLevel());
    return;end;     
    if obj_id==503 then --название levовня
        BlockCursor(false);
      if whole_darkness then
         --затемнилось
      return;end;      
      -- проявление меню вывод собщений в начале levовня ----
      ShowMenu(true);
      --CreateWindow(100,100,"224");             
      ------
    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 == 32 then  --нераспустив цветок
      if attachedID == 40 then
      playeffect("liq");
        RemoveFromMouse(attachedID);
        SetAlfaSheet(2.0)
        DeleteElement("gr",attachedID);
        Set_Cursor(32,3);
        speciale_action(2,32);
        speciale_action(2,33,true);  
        Set_Cursor(33,2);  
        flags.rasp= true;  
        StopEmiter("zvezd");        
      return; end;      
      if (attachedID ~= 40) 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,"202",nil,nil,250,30);
        --playeffect("01");  
      return; end;
    return; end;

    if obj_id == 33 then -- распустив цветок
    if (not flags.minicomplete26) then
    playeffect("06");
      if attachedID == 121 then
        RemoveFromMouse(attachedID);
          playeffect("29");
        add_free_leaf("Root","mini26",0,36);-- Добавляет чистый лист
        set_satelite_leaf("flower");
        DoFile(0,36)
        mini_create();      
        flags.nohints=true;        
      return; end;      
      if (attachedID ~= 121) 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,"203",nil,nil,250,30);
        --playeffect("01");  
      return; end;
    return; end;
    return; end;
    if obj_id == 57 then -- распустив цветок
    if (not flags.minicomplete42) then
      playeffect("29");
        RemoveFromMouse(attachedID);
        add_free_leaf("Root","mini42",0,52);-- Добавляет чистый лист
        set_satelite_leaf("flower");
        DoFile(0,52)
        mini_create();        
          flags.nohints=true;
      if (attachedID ~= 121) 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,"203",nil,nil,250,30);
        --playeffect("01");  
      return; end;
    return; end;
    return; end;
    if obj_id == 43 then --кран без ручки
      if attachedID == 41 then
      playeffect("knock");
        RemoveFromMouse(attachedID);
        SetAlfaSheet(2.0)
        DeleteElement("gr",attachedID);
        Set_Cursor(43,3);
        speciale_action(2,43,true);
        speciale_action(2,42,true);      
        Set_Cursor(42,4);  
        flags.ru4ka  = true;    
      return; end;      
      if (attachedID ~= 41) 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,"204",nil,nil,250,30);
        --playeffect("01");  
      return; end;
    return; end;
    
    if obj_id == 42 then --кран с ручкой
      if not flags.leyka then
        if attachedID == 37 then
        playeffect("MetalOpen");
          RemoveFromMouse(attachedID);
          SetAlfaSheet(2.0)
          DeleteElement("gr",attachedID);
          speciale_action(2,39);
          flags.leyka=true;
        return; end;      
        if (attachedID ~= 37) 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,"205",nil,nil,250,30);
          --playeffect("01");  
        return; end;
      return; end;
      if not flags.first then
      playeffect("voda");
      speciale_action(2,39)
      speciale_action(2,40)
      Set_Cursor(42,3);
      -- Set_Cursor(40,3);
      flags.first= true;
      StopEmiter("kran");
      return;end;
      setcolor(40,0,0,0,1,1);
    return; end;    
      
      if attachedID == -1 then
        if obj_id==501 then
  --        if whole_darkness then
        if flags.levelcomplete then
          delete_tree_leaf("Root","flower");-- Добавляет лист в дерево 
          setnextlavel(15);
          loadlavel();
        return;end;        
            DarkScreen(false);
            whole_darkness=false;
          SetAlfa(503,1,0,1);

    --    return;end;
      return;end;      
      
        if obj_id == 40 then
            collaps_obj(obj_id,0,0,10,0);
            playeffect("20");
        return; end;
        
        if obj_id == 41 then
            collaps_obj(obj_id,0,0,10,0);
              playeffect("20");
        return; end;  

        if obj_id == 37 then
            collaps_obj(obj_id,0,0,10,0);
              playeffect("20");

        return; end;  
        
        if obj_id > 0 and obj_id < 200  then --кликаем на активный объект
          playeffect("20");
          collaps_obj(obj_id,0,0,10,1);
        return 0; end
      
      return; end;
  return; end;

  if sender==14 then
    if obj_id>0 then
    StopSheet=true;
    object=obj_id
      addObjectToMouse(obj_id);
    return; end;
  return; end;      
  -----------------------------------------------На сцене отработали все объекты-------------------------
  if sender==4 then
  -- WriteToConsole("sender = 4, lev14.0".." "..sender.."\n")
  flags.all=true 
  
  return; end;  
------------------------------------------------------------------------------------------------------------------  
  
end
function SelectRandom()
  idObject=GetRandomObject();
  if idObject==40 then
    if not flags.ru4ka then
      selectrandomobject(1.5,43);
    end;
  selectrandomobject(1.5,42);
  end;
  if flags.leyka  then
    if (not flags.minicomplete42) then
      if (not flags.minicomplete26) then
        if not flags.rasp then
          selectrandomobject(1.5,32);
         end;
        selectrandomobject(1.5,33);
      end;
      selectrandomobject(1.5,57);
    end;
   end;
  selectrandomobject(1.5,idObject);
end;
function SelectRandomRadar(idObject)
    if idObject==40 then
      selectrandomobject(1.5,43);
  end;

  selectrandomobject(1.5,idObject);
end;
