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


location={}
location["robert_room"] = true
location["robert_room"] = {}
location["robert_room"]["id"] = 5
location["robert_room"]["sub_id"] = 0
location["photo"] = true
location["photo"] = {}
location["photo"]["id"] = 5
location["photo"]["sub_id"] = 1
location["cherdak"] = true
location["cherdak"] = {}
location["cherdak"]["id"] = 5
location["cherdak"]["sub_id"] = 2



function LoadingLevel(param)
    SetAlfaValue(501,0)
	SetAlfaValue(503,0)
	SLevel=param;
return;end;

function LevelComplete()
	flags.levelcomplete=true;
	setcurentleaf("robert_room",5,0);
		DeleteElement("gr",106);
		DeleteElement("gr",110);
		DeleteElement("gr",115);
		DeleteElement("gr",107);
		DeleteElement("gr",146);
	setcurentleaf("photo",5,1);	
		DeleteElement("gr",1018);
		DeleteElement("gr",1027);
		DeleteElement("gr",1028);
		DeleteElement("gr",1033);
		DeleteElement("gr",1038);
		DeleteElement("gr",1043);
	setcurentleaf("cherdak",5,2);		
		DeleteElement("gr",346);
		DeleteElement("gr",305);
		DeleteElement("gr",333);
		DeleteElement("gr",334);
		DeleteElement("gr",348);
	StopEmiter("fireplace");
	DarkScreen(true);
	ShowMenu(false);
end;

function StartLevel()
	setcurentleaf("robert_room",5,0);
		AddParticleToObject(61,"fireplace",0,0,0,0);
		StartEmiter("fireplace");
		MoveEmiter("fireplace",313,435);	
		AddParticleToObject(11,"candle",0,0,0,0);
		StartEmiter("candle");		
		AddParticleToObject(19,"PhotoOn",0,0);
		AddParticleToObject(31,"BoxOn",0,0);
		AddParticleToObject(42,"Urna",0,0);			
		MoveEmiter("PhotoOn",663,252);
		MoveEmiter("BoxOn",867,495);
		MoveEmiter("Urna",240,550);	
		if not flags.lens and flags.flash then
			StartEmiter("PhotoOn");
		end;
		if not flags.lens and flags.flash then
			StartEmiter("PhotoOn");
		end;	
		if (flags.lens and flags.flash) and not flags.minicomplete then
			AddParticleToObject(17,"Photo",676,262);
			StartEmiter("Photo");
			MoveEmiter("Photo",676,262);	
		end;			
		if not flags.box then
			StartEmiter("BoxOn");
		end;
		if flags.box and not flags.minicomplete2 then
			AddParticleToObject(32,"Box",895,531);
			StartEmiter("Box");
			MoveEmiter("Box",895,531);		
		end;
		if not flags.minicomplete1 then
			StartEmiter("Urna");				
		end;
	setcurentleaf("photo",5,1);	
		AddParticleToObject(48,"Zamok",0,0);
		AddParticleToObject(29,"Bottle",762,622);
		AddParticleToObject(37,"Urna1",0,0);	
		AddParticleToObject(45,"LampOn",0,0);	
		AddParticleToObject(53,"Prov",0,0);					
		MoveEmiter("Zamok",81,93);
		MoveEmiter("Bottle",762,622);
		MoveEmiter("Urna1",544,513);	
		MoveEmiter("LampOn",721,94);
		MoveEmiter("Prov",609,381);	
		if not flags.minicomplete4 then
			StartEmiter("Prov");
		end			
		if not flags.lock then	
			StartEmiter("Zamok");
		end;	
		if not flags.minicomplete5 then
			StartEmiter("Bottle");
		end;
		if not flags.minicomplete6 then
			StartEmiter("Urna1");	
		end;
		if not flags.lamp then
			StartEmiter("LampOn");
		end;
		if flags.lamp and not flags.minicomplete3 then
			AddParticleToObject(42,"Lamp",0,0);
			StartEmiter("Lamp");
			MoveEmiter("Lamp",705,276);				
		end;
	setcurentleaf("cherdak",5,2);
		AddParticleToObject(11,"Emitter",0,0);
		MoveEmiter("Emitter",383,392);
		StartEmiter("Emitter");	
		AddParticleToObject(38,"RWOn",0,0);
		AddParticleToObject(45,"Furniture",577,444);		
		MoveEmiter("RWOn",616,577);
		MoveEmiter("Furniture",577,444);	
		if not flags.parts then	
			StartEmiter("RWOn");
		end;
		if flags.parts and not flags.minicomplete7 then
			AddParticleToObject(38,"RW",570,547);
			StartEmiter("RW");
			MoveEmiter("RW",570,547);			
		end;
		if not flags.minicomplete8 then
			StartEmiter("Furniture");
		end;	
end;



frame=-1;
flags={};
flags["filtr"]=false;
flags["paper"]=false;
flags["photo"]=false;

flags["water"]=false;
flags["reakt"]=false;
flags["photo1"]=false;
flags["whole_darkness"]=false;
flags["loc1"]=false;
flags["loc2"]=false;
flags["loc3"]=false;
flags["firstloc2"]=true;
flags["firstloc3"]=true;
flags["levelcomplete"]=false;
flags["lens"] = false;
flags["flash"] = false;
flags["lamp"]=false;
flags["skip"]=false;

flags["film"]=false;
flags["photopaper"]=false;
flags["reaktivi"]=false;
flags["lightfilter"]=false;
flags["litr"]=false;
flags["emptyslot"]=true;

flags["parts"]=false;
flags["bluewire"]=false;
flags["redwire"]=false;
flags["fuel"]=false;
flags["trans"]=false;

flags["mini_bluewire"]=false;
flags["mini_redwire"]=false;
flags["mini_fuel"]=false;
flags["mini_trans"]=false;

flags["minitext1"]=false;
flags["minitext2"]=false;

flags["mini6run"]=false;
flags["minicomplete"]=false;
flags["minicomplete1"]=false;
flags["minicomplete2"]=false;
flags["minicomplete3"]=false;
flags["minicomplete4"]=false;
flags["minicomplete5"]=false;
flags["minicomplete6"]=false;
flags["minicomplete7"]=false;
flags["minicomplete8"]=false;

flags["allobject1"]=false;
flags["allobject2"]=false;
flags["allobject3"]=false;

flags["minitext1"]=false;

flags["photo1_in"]=false;
flags["photo2_in"]=false;
flags["lock"]=false;
flags["box"]=false;
flags["film_in"]=false;
flags["HintCount"]=5;
flags["comics"]=false

add_tree_leaf("Root","robert_room",5,0);-- Добавляет лист в дерево 
SetCurrentRM("menu");
        addstaticobjecttogame(877777777,"menubuttons",63,622,"",60,0,61,61);
		AddSheet(1002,"re","red_b",63,622,61,61,"",128,640,650,115,15,5,7,7,0,59,877777777);
SetCurrentRM("main");
ShowMenu(false);
loadresource("data\\photoaparat.png","photoaparat",112121212);
AddImgToBook("photoaparat",838,580);
AddHints()
dofile("./data/5/0/res.lua");

add_tree_leaf("Root","photo",5,1);
SetCurrentRM("menu");
addstaticobjecttogame(877777777,"menubuttons",63,622,"",60,0,61,61);
AddSheet(1002,"re","red_b",63,622,61,61,"",128,640,650,115,15,5,7,7,0,59,877777777);
SetCurrentRM("main");
dofile("./data/5/1/res.lua");

add_tree_leaf("Root","cherdak",5,2);

SetCurrentRM("menu");
addstaticobjecttogame(877777777,"menubuttons",63,622,"",60,0,61,61);
AddSheet(1002,"re","red_b",63,622,61,61,"",128,640,650,115,15,5,7,7,0,59,877777777);
SetCurrentRM("main");
dofile("./data/5/2/res.lua");

setcurentleaf("robert_room",5,0);
		SwitchToSheet("re");
		DarkScreen(true);
		speciale_action(2,503,true);	
		speciale_action(4,503)

playfile(".\\sound\\Music_1.ogg",true,true);