--------------------------------------------------------------------------------
--  File     : Chapel_ext_Door_MG
--  Author(s): Prokopovich Larisa
--
--  Summary  : Скрипт управления локацией.
--
--  Copyright © 2012 Floodlight Games.  All rights reserved.
--------------------------------------------------------------------------------
function OnFirstEntry()
	stars:Show("M_LOCK", "4")
end
--------------------------------------------------------------------------------
function OnMouseClickOnItem(item)
	local itemName = item:GetName()
	
	if itemName == "M_BACK" then
		chapter:JumpRoom("Chapel_ext")
		return true
		
	elseif itemName == "M_LOCK" then			--замок на двери
		comment:Add("CMT_Lock_Player")
		return true
	end
end
--------------------------------------------------------------------------------
function OnClickItemOnItem(item)					
	local itemName = item:GetName()
	
	if itemName == "M_LOCK" then				--кольцо на замок
		if cursor:IsItemNameEqual("CIRCLE") then			
			cursor:RemoveItem()
			item:Hide()
			room:GetItem("C1"):Show()
			room:GetItem("C1_HOLES"):Show()
			room:GetItem("C1_LIGHT"):Show()
			room:GetItem("C1_SHADOW"):Show()
			room.sfx:Play ("insert_ring")
			
			--вызов функции запуска пазла из кода
			room:Start()	
			solve:Enable(true)
			return true
		end
	end
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function OnPuzzleWin()
	if room:GetItem("C1"):IsVisible() then
		room.sfx:Play ("puzzle_done")			--звук "замок полностью открывается"
		OnPuzzleWin1()
		chapter:JumpRoom("Chapel_ext")
	end
end
--------------------------------------------------------------------------------
function OnPuzzleWin1()
	comment:Add("CMT_Open_Player")
	solve:Enable(false)
	cstore:SetKey("Chapel_door", true)
	room:MarkCompleted()
end


