dofile("script\\gamemenu.lua");
dofile("script\\lib.lua");

set_inpun_fun("gameinput");
location={}
location["barton_vhod"] = true
location["barton_vhod"] = {}
location["barton_vhod"]["id"] = 1
location["barton_vhod"]["sub_id"] = 0
location["barton_zal"] = true
location["barton_zal"] = {}
location["barton_zal"]["id"] = 1
location["barton_zal"]["sub_id"] = 1
location["oranjereya"] = true
location["oranjereya"] = {}
location["oranjereya"]["id"] = 1
location["oranjereya"]["sub_id"] = 2
function LevelComplete()
    DeleteElement("gr",102);
    DeleteElement("gr",155);
  DeleteElement("gr",104);
  DeleteElement("gr",164);
  DeleteElement("gr",141);
  DeleteElement("gr",110);
  DeleteElement("gr",221);
  DeleteElement("gr",105);
  DeleteElement("gr",65);
  flags.address=true;
    setcurentleaf("barton_zal",1,1);
    AddElement("gr",108);
    MoveObjectToTree(108);
    AddElement("gr",109);
    MoveObjectToTree(109);
    setcurentleaf("oranjereya",1,2);
    AddElement("gr",106);
    MoveObjectToTree(106);
    AddElement("gr",111);
    MoveObjectToTree(111);
  flags.levelcomplete=true;
  whole_darkness=false;
  DarkScreen(true);
  ShowMenu(false)
end;
function LoadNextLevel()
--SetAlfaValue(501,0);
SetAlfaValue(503,0);
  delete_tree_leaf("Root","barton_vhod");-- Добавляет лист в дерево 
  delete_tree_leaf("Root","barton_zal");-- Добавляет лист в дерево 
  delete_tree_leaf("Root","oranjereya");-- Добавляет лист в дерево 
  setnextlavel(2);

  loadlavel();
end;

function LoadingLevel(param)
if flags.levelcomplete then
  delete_tree_leaf("Root","barton_vhod");-- Добавляет лист в дерево 
  delete_tree_leaf("Root","barton_zal");-- Добавляет лист в дерево 
  delete_tree_leaf("Root","oranjereya");-- Добавляет лист в дерево 
  setnextlavel(2);
  loadlavel();
return; end;
SetAlfaValue(503,0);
     SLevel=param;
return;end;
frame=0;

flags={};
flags["comx"]=false;
flags["comx1"]=false;
flags["loc1"] = false;
flags["loc2"] = false;
flags["loc3"] = false;
flags["minicomplete"]=false;
flags["minicomplete11"]=false;
flags["minicomplete35"]=false;
flags["minicomplete16"]=false;
flags["minicomplete54"]=false;
flags["minicomplete15"]=false;
flags["minicomplete6"]=false;
flags["energyclose"]=true;
flags["lamp"]=true;
flags["stairs"] = false;
flags["cat"] = true;
flags["light"]=false;
flags["light1"]=false;
flags["address"]=false;
flags["enter"]=false;
flags["firstloc2"]=false;
flags["firstloc3"]=false;
flags["priexal"]=true;
flags["darkness"]=true;
flags["babo4ka"]=false;
flags["lampo4ka"]=false;
flags["HintCount"]=5;
flags["card"]=false;
flags["match"]=false;
flags["flowerpot"]=false;
flags["photo"]=false;
flags["door"]=false;
flags["levelcomplete"]= false;
flags["first"]= false;
flags["first1"]= false;
flags["nohints"]=false;
flags["posvetlelo"]=false;
flags["fonaction"]=false;
flags["closeletter"]=false;

skip=false;

add_tree_leaf("Root","barton_vhod",1,0);-- Добавляет лист в дерево 
  addstaticobjecttogame(877777777,"buttons",114,625,"",60,0,61,61);
  SetCurrentRM("menu");
  AddSheet(1002,"re","red_b",103,656,37,41,"",99,657,650,80,92,21,5,5,0,59,877777777,nil,"buttonsY");
  SetCurrentRM("main");
  ShowMenu(false);
dofile("./data/1/0/res.lua");  
 UpdateStack();
loadresource("data\\photoaparat.png","photoaparat",2000029);
loadresource("data\\animationMENU3.png","menuAn",2000030);
AddImgToBook("photoaparat",821,637);
AddHints()
add_tree_leaf("Root","barton_zal",1,1);
  addstaticobjecttogame(877777777,"buttons",114,625,"",60,0,61,61);
  SetCurrentRM("menu");
  AddSheet(1002,"re","red_b",103,656,37,41,"",99,657,645,80,92,21,5,5,0,59,877777777,nil,"buttonsY");
SetCurrentRM("main");  
dofile("./data/1/1/res.lua");  
   UpdateStack();
add_tree_leaf("Root","oranjereya",1,2);
  addstaticobjecttogame(877777777,"buttons",114,625,"",60,0,61,61);
  SetCurrentRM("menu");
  AddSheet(1002,"re","red_b",103,656,37,41,"",99,657,650,80,92,21,5,5,0,59,877777777,nil,"buttonsY");
SetCurrentRM("main");  
dofile("./data/1/2/res.lua");  
 UpdateStack();
playfile(".\\sound\\game_theme2.ogg",true,true);
setcurentleaf("barton_vhod",1,0);
WaitRender()
flags.comx= true

ShowMenu(false);
-- SetDrawSheet("re",false)
-- SetDrawSheet("gr",false)
function StartLevel()
if flags.levelcomplete then
    SetAlfaValue(503,1);
    SetAlfaValue(501,1);
  return; end;  
  DarkScreen(false);
  SetCurrentRM("menu");
  AddImgToBook("photoaparat",821,637);
  AddHints()
  SetCurrentRM("main");
  ShowMenu(true);
setcurentleaf("barton_vhod",1,0);
if flags.fonaction then
set_visible_object(66, false)
end
  AddParticleToObject(72,"pu4ok",228,159);
  MoveEmiter("pu4ok",228,159);
  if (not flags.minicomplete16) then --адрес
    StartEmiter("pu4ok");
  end;
  AddParticleToObject(45,"Svet4",225,361);
  MoveEmiter("Svet4",225,361);
  AddParticleToObject(46,"zvezd1",246,342);
  MoveEmiter("zvezd1",246,342);
  AddParticleToObject(45,"Svet14",225,361);
  MoveEmiter("Svet14",225,361);

  if (not flags.vikl) then
    if  flags.energyclose then 
      StartEmiter("zvezd1"); 
    end;    
    if not flags.energyclose then  
      StartEmiter("Svet4");
    end;
  end;
  if flags.vikl then  
    if flags.light then  
    if not flags.minicomplete35 then
      StartEmiter("Svet14"); 
    end;  
  end;
  end;
setcurentleaf("barton_zal",1,1);

-- messagebox("barton_zal");
AddParticleToObject(62,"Svet",200,437);
MoveEmiter("Svet",200,437);
AddParticleToObject(28,"cat",791,493);
MoveEmiter("cat",791,493);
AddParticleToObject(29,"pu4ok1",787,587);
MoveEmiter("pu4ok1",787,587);
if flags.cat then
StartEmiter("cat");
end;
if  not flags.minicomplete11 then -- комод
StartEmiter("Svet");
end;
if not flags.minicomplete54 and not flags.cat then
StartEmiter("pu4ok1"); 
end;
setcurentleaf("oranjereya",1,2);
  -- messagebox("oranjereya");
    AddParticleToObject(69,"patron",714,91);
    MoveEmiter("patron",714,91);

  AddParticleToObject(105,"babo4ka",110,460);
  MoveEmiter("babo4ka",110,460);
  AddParticleToObject(54,"pu4ok2",835,551);
  MoveEmiter("pu4ok2",835,551);
  if not flags.babo4ka then --кейс
  StartEmiter("babo4ka"); 
  end;
  if flags.minicomplete15 and not flags.minicomplete15 then --спички
  StartEmiter("pu4ok2"); 
  end;
          if not ligth then
          StartEmiter("patron"); 
        end;
end

