local function StartComics()
  local a,b = 325,275

  AddParticleToObject(509,"top_left")
  MoveEmiter("top_left",a,b)
  StartEmiter("top_left")
  AddParticleToObject(507,"top_right")
  MoveEmiter("top_right",1024-a,b)
  StartEmiter("top_right")
  AddParticleToObject(508,"bottom_right")
  MoveEmiter("bottom_right",1024-a,768-b)
  StartEmiter("bottom_right")
  AddParticleToObject(510,"bottom_left")
  MoveEmiter("bottom_left",a,768-b)
  StartEmiter("bottom_left")  
  speciale_action(2,711,true,1)
end;



function FinishComics()
  Block_Show_Cur(false)
  flags.is_comics=false;
  CreatePlashechka("646")  
  
  StartEmiter("Hidden_2_1");

  Journal:addText(3,"9005",170,331,330)
  Journal:addPicture(3,"page3",156,61,0,0,860,540);  

  flags.ubili=true

end;



 function LoadComics()
  Block_Show_Cur(true)  
  addstaticobjecttogame(721,"comics1",305,274,"",0,0,120,152);
  addstaticobjecttogame(720,"comics1",101,274,"",120,0,324,228);
  addstaticobjecttogame(719,"comics1",109,274,"",444,0,316,188);
  addstaticobjecttogame(718,"comics1",119,274,"",120,228,306,152);
  addstaticobjecttogame(717,"comics1",144,264,"",444,188,281,162);
  addstaticobjecttogame(716,"comics1",179,270,"",760,0,246,156);
  addstaticobjecttogame(715,"comics1",202,269,"",725,188,223,157);
  addstaticobjecttogame(714,"comics1",233,272,"",444,350,192,154);
  addstaticobjecttogame(713,"comics1",242,272,"",725,345,183,154);
  addstaticobjecttogame(712,"comics1",248,273,"",120,380,177,153);
  addstaticobjecttogame(711,"comics1",248,273,"",444,504,177,153);
  addstaticobjecttogame(507,"comics1",0,0  ,"",489,90,1,1)-- chel_0_0
  addstaticobjecttogame(508,"comics1",0,0  ,"",489,90,1,1)-- chel_0_0
  addstaticobjecttogame(509,"comics1",0,0  ,"",489,90,1,1)-- chel_0_0
  addstaticobjecttogame(510,"comics1",0,0  ,"",489,90,1,1)-- chel_0_0  
  for i=711,721,1 do
    speciale_action(2,i)
  end;
  for i=711,721,1 do
    speciale_action(4,i)
  end;
  for i=507,510,1 do
    speciale_action(4,i)
  end;    
  StartComics()
end;



playeffect("birds_sing",true)
-- Скрипты всех локаций строятся по одному шаблону

-- Здесь устанавливаются курсоры. Не в рес.луа потому что
-- левел.луа выполняется при каждом заходе на локацию, а рес.луа -
-- только при заходе на не созданную локацию
setCursor(obj.door_Ozero_2_0.id,8);
setCursor(obj.door_VorotaMuzeya_2_0.id,5);
setCursor(obj.door_DorogaKMuzeyuHidden_2_0.id,2);
setCursor(obj.mini_Vetka_2_0.id,2);
setCursor(obj.mini_VnutriLeva_2_0.id,2);
setCursor(obj.mini_DorogaKMuzeyuZnak_2_0.id,2);
setCursor(obj.Lev_2_0.id,4);
setCursor(542,6)

if not neighbors.Lions.lock then
  set_visible_object(201,true)
  set_visible_object(200,false)
else
  set_visible_object(200,true)
  set_visible_object(201,false)
end


-- Подсказка
function SelectRandom()
  if not neighbors.Lions.lock and flags.videlLyvov then
    giveMeHint(obj.mini_DorogaKMuzeyuZnak_2_0.id);
  return end
  if obj.topor_12_1 and obj.topor_12_1.is_collapsed and not neighbors.Vetka.lock then
    giveMeHint(obj.mini_Vetka_2_0.id);
  return end
  if not neighbors.DorogaKMuzeyuHidden.lock then
    giveMeHint(obj.door_DorogaKMuzeyuHidden_2_0.id);
  return end
  if not flags.levUpal then
    giveMeHint(obj.Lev_2_0.id);
  return end
  if obj.shpilka_12_14 and obj.shpilka_12_14.is_stored then
    giveMeHint(obj.mini_VnutriLeva_2_0.id);
  return end
  CreatePlashechka("10001")
end;


-- Дальше идёт логика. Именно здесь, а не где-нибудь
-- в 100-м сендере или в 30-сендере сателлита.
-- Мне кажется, удобство очевидно.

-- if not mustbetutorial then 
  -- mustbetutorial=true
  if not flags.hinttutorial and flags.ShowTutorial then
    flags.hinttutorial=true
    CreateTutorial("10010",350,280,0)
    flags.mes_tutorial=4;
  end;  
--end;

if mustbecomics then
mustbecomics=false
LoadComics() 
flags.is_comics=true;
end;

if neighbors.DorogaKMuzeyuHidden.lock then
  set_visible_object(obj.door_DorogaKMuzeyuHidden_2_0.id,false)
end
if flags.levUpal then
  set_visible_object(obj.Lev_2_0.id,false)
  set_visible_object(obj.Oskolki_2_0.id,true)
  set_visible_object(obj.mini_DorogaKMuzeyuZnak_2_0.id,true)
  set_visible_object(obj.mini_VnutriLeva_2_0.id,true)
else
  set_visible_object(obj.mini_DorogaKMuzeyuZnak_2_0.id,false)
  set_visible_object(obj.mini_VnutriLeva_2_0.id,false)
end
if neighbors.Lions.lock then
  set_visible_object(obj.mini_DorogaKMuzeyuZnak_2_0.id,false)
end
if neighbors.Vetka.lock then
  set_visible_object(obj.mini_Vetka_2_0.id,false)
end

if neighbors.VnutriLeva.lock then
  set_visible_object(obj.mini_VnutriLeva_2_0.id,false)
end

if not flags.plashechka_2_0 then
  Journal:addText(2,"9002",163,423,330)
  Journal:addText(2,"9003",587,503,330)
  Journal:addPicture(2,"page2",129,23,0,0,451,449);
  Journal:addPicture(2,"page2",575,127,451,0,306,365);
  
  flags.plashechka_2_0 = true
  --CreatePlashechka("663")
end


-- И, наконец, обработка ввода
-- 100-й сендер выдаёт Викину руку. Я его не использую вообще. Он не нужен.
function gameinput (sender,obj_id,attachedID)
--  if not flags.is_comics then
    sendersProcessing(sender,obj_id,attachedID)
--  end;  
  
  -- if sender==121 and mustbetutorial then
    -- mustbetutorial=false
    -- if not flags.hinttutorial and flags.ShowTutorial then
      -- flags.hinttutorial=true
      -- CreateTutorial("10010",350,280,0)
      -- flags.mes_tutorial=4;
    -- end;      
  -- end;
  
  if sender==16 then
    if obj_id==716 then
    playeffect("shoot")
    end;
    if obj_id>=711 and obj_id<=720 then
      speciale_action(2,obj_id,true,1)
      speciale_action(2,obj_id+1,true,1.1)
    return;end;
    if obj_id==721 then
      speciale_action(2,obj_id,true,2)
      StopEmiter("top_left",true)
      StopEmiter("top_right",true)
      StopEmiter("bottom_right",true)
      StopEmiter("bottom_left",true)  
      StartTimer(timerID,1.5,"FinishComics")          
    return;end;
  return;end;
  
  if sender==154 then
    if flags.ShowTutorial then
    nexttutorial=true
    WaitRender()
    end;
  end;  
  if sender==100 then
    if nexttutorial then
      if flags.mes_tutorial==4 then
         CreateTutorial("10011",32,5,0)
         nexttutorial=false
         flags.mes_tutorial=5;
      end;      
    end;  
  end;  
  if sender==1 then
--    if not flags.is_comics then
      if obj_id == obj.Lev_2_0.id then
        Block_Show_Cur(true)
        speciale_action(2,obj.Lev_2_0.id,true,0.1)
        speciale_action(2,obj.Lev2_2_0.id,true,0.1)
        StartTimer(timerID,0.11,"frame1")
      end
      if obj_id == obj.door_Ozero_2_0.id then
        jump("Ozero");
      end;
      if obj_id == obj.door_VorotaMuzeya_2_0.id then
        jump("VorotaMuzeya");
      end;
      if obj_id == obj.door_DorogaKMuzeyuHidden_2_0.id then
        flags.is_hidden_loc = true;
        jump("DorogaKMuzeyuHidden");
      end;
      if obj_id == 542 then
        jump("Street");
      end;    
      if obj_id == obj.mini_Vetka_2_0.id then
        CreateSatelite("Vetka");
        playeffect("sat")
      end;
      if obj_id == obj.mini_DorogaKMuzeyuZnak_2_0.id then
        CreateSatelite("Lions")
        playeffect("sat")
      end;
      if obj_id == obj.mini_VnutriLeva_2_0.id then
        CreateSatelite("VnutriLeva")
        playeffect("sat")
      end;
    end;
  --end
end

-- Все асинхронные вызовы я делаю callback-ами
function frame1()
  speciale_action(2,obj.Lev2_2_0.id,true,0.1)
  speciale_action(2,obj.Lev3_2_0.id,true,0.1)
  StartTimer(timerID,0.11,"frame2")
end

function frame2()
  speciale_action(2,obj.Lev3_2_0.id,true,0.1)
  speciale_action(2,obj.Oskolki_2_0.id,true,0.1)
  StartEmiter("lev_2_0")
  playeffect("statue")
  StartTimer(timerID,0.11,"frame3")
end

function frame3()
  set_visible_object(obj.mini_DorogaKMuzeyuZnak_2_0.id,true)
  set_visible_object(obj.mini_VnutriLeva_2_0.id,true)
  StopEmiter("lev_2_0",true);
  flags.levUpal = true
  Block_Show_Cur(false)
  CreatePlashechka("632")
end