dofile("script\\gamemenu.lua");
dofile("script\\lib.lua");
set_inpun_fun("gameinput");
location={}
location["barton_vhod"] = true
location["barton_vhod"] = {}
location["barton_vhod"]["id"] = 5
location["barton_vhod"]["sub_id"] = 0
location["barton_zal"] = true
location["barton_zal"] = {}
location["barton_zal"]["id"] = 5
location["barton_zal"]["sub_id"] = 1
function LevelComplete()
setcurentleaf("barton_zal",5,1);
  AddElement("gr",109);
  MoveObjectToTree(109);    
  AddElement("gr",113);
  MoveObjectToTree(113);
  DeleteElement("gr",211);
  DeleteElement("gr",208);
  DeleteElement("gr",112);
  flags.levelcomplete=true;
    whole_darkness=false;
  DarkScreen(true);
  ShowMenu(false)
end;
function LoadingLevel(param)
if flags.levelcomplete then
  delete_tree_leaf("Root","barton_vhod");-- Добавляет лист в дерево 
  delete_tree_leaf("Root","barton_zal");-- Добавляет лист в дерево 
  setnextlavel(6);
  loadlavel();
return; end;
SetAlfaValue(503,0);
     SLevel=param;
return;end;
function LoadNextLevel()
  delete_tree_leaf("Root","barton_vhod");-- Добавляет лист в дерево 
  delete_tree_leaf("Root","barton_zal");-- Добавляет лист в дерево 
  setnextlavel(6);
  loadlavel();  
end;
frame=0;
flags={};
flags["comx"]=false;
flags["comx1"]=false;
flags["loc1"] = false;
flags["firstloc2"] =false;
flags["loc2"] = false;
flags["minicomplete"]=false;
flags["minicomplete1"]=false;
flags["minicomplete2"]=false;
flags["minicomplete3"]=false;
flags["energy"]=false;
flags["cat"]=true;
flags["globe"]=false;
flags["button"]=false;
flags["door"]=false;
flags["receipt"]=false;
flags["card"]=false;
flags["bell"]=false;
flags["levelcomplete"]= false;
flags["nohints"]=false;
flags["first"]= false;
flags["proideno"]=false;
skip=false;
flags["HintCount"]=5;

function StartLevel()

  -- local s="";
  -- if flags.loc1 then s=s.."flags.loc1=true\n" else s=s.."flags.loc1=false\n"; end;
  -- if flags.firstloc2 then s=s.."flags.firstloc2=true\n" else s=s.."flags.firstloc2=false\n"; end;
  -- if flags.loc2 then s=s.."flags.loc2=true\n" else s=s.."flags.loc2=false\n"; end;
  -- if flags.minicomplete then s=s.."flags.minicomplete=true\n" else s=s.."flags.minicomplete=false\n"; end;
  -- if flags.minicomplete1 then s=s.."flags.minicomplete1=true\n" else s=s.."flags.minicomplete1=false\n"; end;
  -- if flags.minicomplete2 then s=s.."flags.minicomplete2=true\n" else s=s.."flags.minicomplete2=false\n"; end;
  -- if flags.minicomplete3 then s=s.."flags.minicomplete3=true\n" else s=s.."flags.minicomplete3=false\n"; end;
  -- if flags.energy then s=s.."flags.energy=true\n" else s=s.."flags.energy=false\n"; end;
  -- if flags.cat then s=s.."flags.cat=true\n" else s=s.."flags.cat=false\n"; end;
  -- if flags.globe then s=s.."flags.globe=true\n" else s=s.."flags.globe=false\n"; end;
  -- if flags.button then s=s.."flags.button=true\n" else s=s.."flags.button=false\n"; end;
  -- if flags.door then s=s.."flags.door=true\n" else s=s.."flags.door=false\n"; end;
  -- if flags.receipt then s=s.."flags.receipt=true\n" else s=s.."flags.receipt=false\n"; end;
  -- if flags.card then s=s.."flags.card=true\n" else s=s.."flags.card=false\n"; end;
  -- if flags.bell then s=s.."flags.bell=true\n" else s=s.."flags.bell=false\n"; end;
  -- if flags.levelcomplete then s=s.."flags.levelcomplete=true\n" else s=s.."flags.levelcomplete=false\n"; end;
  -- if flags.first then s=s.."flags.first=true\n" else s=s.."flags.first=false"; end;
  -- messagebox(s);
setcurentleaf("barton_vhod",5,0)
  AddParticleToObject(39,"zvezd",526,280);---zvon
  MoveEmiter("zvezd",526,280);

  if not flags.button then
  StartEmiter("zvezd"); 
  end;

setcurentleaf("barton_zal",5,1)
  AddParticleToObject(31,"zvezd3",212,316);
  MoveEmiter("zvezd3",212,316);
  AddParticleToObject(56,"globus",827,429);
  MoveEmiter("globus",827,429);
  if  flags.cat then
  StartEmiter("zvezd3");
  end;
  if (not flags.cat) and (not flags.minicomplete4) then
  StartEmiter("globus"); 
  end;
  DarkScreen(false);
  SetCurrentRM("menu");
  AddImgToBook("photoaparat",821,637);
  AddHints()
  SetCurrentRM("main");
  ShowMenu(true);
end
add_tree_leaf("Root","barton_vhod",5,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,1,"buttonsY");
  SetCurrentRM("main");
  loadresource("data\\photoaparat.png","photoaparat",2000029);
loadresource("data\\animationMENU3.png","menuAn",2000030);
AddImgToBook("photoaparat",821,637);
AddHints()

dofile("./data/5/0/res.lua");
 UpdateStack();
add_tree_leaf("Root","barton_zal",5,1);-- Добавляет лист в дерево 
  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,1,"buttonsY");
  SetCurrentRM("main");
dofile("./data/5/1/res.lua");
 UpdateStack();
setcurentleaf("barton_vhod",5,0);
WaitRender()
flags.comx= true;
    ShowMenu(false);
playfile(".\\sound\\game_theme2.ogg",true,true);