--------------------------------------------------------------------------------
--  File     : Witch's_house_ext_Flowerbed
--  Author(s): Prokopovich Larisa
--
--  Summary  : Скрипт управления локацией.
--
--  Copyright © 2012 Floodlight Games.  All rights reserved.
--------------------------------------------------------------------------------
function OnFirstEntry()
	stars:Show("M_INSECTS", "4")
end
--------------------------------------------------------------------------------
function OnEntry()
	room.sfx:PlayEx ("flies", true, 1, 0)	--звук "мухи жужжат (циклично) пока их на липкую тряпку не посадим"
end

--------------------------------------------------------------------------------
function OnMouseClickOnBack()
	chapter:ExitCloseup()
	return true
end

--------------------------------------------------------------------------------
function OnMouseClickOnItem(item)
	local itemName = item:GetName()
	
	if itemName == "M_INSECTS" then 				--мухи на клумбе
		if cstore:IsKeyExists("Flytrap_seen") then
			comment:Add("CMT_Insect2_Player")
			cstore:SetKey("Flytrap_seen", 2)
		else
			comment:Add("CMT_Insect1_Player")
		end
		return true
	end
end
--------------------------------------------------------------------------------
function OnClickItemOnItem(item)					--липкий лоскут на мух	
	local itemName = item:GetName()

	if itemName == "M_INSECTS" then
		if cursor:IsItemNameEqual("RAG_STICKY") then			
			cursor:RemoveItem()
			item:Hide()
			cstore:SetKey("Close_up_Flowerbed", true)
			
			local rag_insects = room:GetItem("RAG_INSECTS")
			rag_insects:Show()
			rag_insects:PlayAnimation()
			room:AddCtrlAnimation("RAG_INSECTS", -1)
			return true
		end
	end
end
--------------------------------------------------------------------------------
-- Окончание анимации нацепливания мух на тряпку
function OnAnimationComplete_RAG_INSECTS(forced)
	room:GetItem("RAG_INSECTS"):Hide()
	room:MarkCompleted()
	
	if forced == true then
		inventory:CreateAndAddItem(room:GetItem("RAG_INSECT"))
	else
		pick_panel:AddItems("RAG_INSECT", true)
	end
end


