HouseType = 4
SawmillType = 5
MarketType = 7
BankType = 6

function ShowFAN()
	GUI:getLayer("Game"):getWidget("Game"):AcceptMessage(Message("ShowFirstActionNotification"))
end

function HideFAN()
	GUI:getLayer("Game"):getWidget("Game"):AcceptMessage(Message("HideFirstActionNotification"))
end

tutorialFunctionTable = {}

function TutorialResetFunction(message)
	tutorial:variables():setBool("TutorialRentgenEnabled", true)
	tutorial:variables():setInt("TutorialState", 0)
	tutorial:variables():setBool("TutorialLock", false)
	tutorial:variables():setFloat("Tutorial_Smart_MoreTaxers_Time", 0.0)
	tutorial:variables():eraseName("TutorialArrowsNoBind")
	tutorialFunctionTable = {}
	tutorial:syncJumpWidget("MoneyCount", -1)
	tutorial:syncJumpWidget("MaterialsCount", -1)
	tutorial:syncJumpWidget("WorkersCount", -1)
	tutorial:syncJumpWidget("FoodCount", -1)
	tutorial:syncJumpWidget("HappinessCount", -1)
end

function onEndPassTutorialFunc(message)
	GUI:getLayer("Game"):getWidget("Game"):AcceptMessage(Message("Continue"))
	tutorial:hide(0.25)
end

function onEndFirstPassTutorialFunc(message)
	GUI:getLayer("Game"):getWidget("Game"):AcceptMessage(Message("Continue"))
end

function FirstPassTutorialFunc(message)
	if message:is("Yes", "press") then
		if (not gameInfo:getActiveBetaStat():findName("FirstPassTutorial")) then
			gameInfo:getActiveBetaStat():setBool("FirstPassTutorial", true)
		end
		TutorialCommonFunction(Message("TutorialPass", "press"))
		FlyPushLayer("FirstPassTutorial", "FirstPassTutorial", 1, "onEndPassTutorialFunc")
	elseif message:is("No", "press") then
		if (not gameInfo:getActiveBetaStat():findName("FirstPassTutorial")) then
			gameInfo:getActiveBetaStat():setBool("FirstPassTutorial", false)
		end
		FlyPushLayer("FirstPassTutorial", "FirstPassTutorial", 1, "onEndFirstPassTutorialFunc")
	end	
end

function PassTutorialFunc(message)
	if message:is("Yes", "press") then
		gameInfo:setHintsEnabled(false)
		gameInfo:setPassTutorialCount(0)
		if (not gameInfo:getActiveBetaStat():findName("PassTutorial")) then
			gameInfo:getActiveBetaStat():setBool("PassTutorial", true)
		end
		FlyPushLayer("PassTutorial", "PassTutorial", 1, "onEndPassTutorialFunc")
	elseif message:is("No", "press") then
		if (not gameInfo:getActiveBetaStat():findName("PassTutorial")) then
			gameInfo:getActiveBetaStat():setBool("PassTutorial", false)
		end
		FlyPushLayer("PassTutorial", "PassTutorial", 1, "onEndPassTutorialFunc")
	end	
end

function TutorialCommonFunction(message)
	if (message:is("LoadLevel")) then
		tutorial:reset()
		if (_G[message:getData()] ~= nil) then
			tutorial:variables():setString("LevelTutorialFunction", message:getData())
		else
			tutorial:variables():setBool("TutorialToSelect", true)
		end
	--[[
	elseif message:is("TutorialSkip", "press") then
		DialogSkip()
	]]
	elseif (message:is("TutorialPass", "press")) then
		ShowFAN()
		-- если мы находимся в игре, то обязительно есть функция туториала (иначе это история Жени)
		if (tutorial:variables():findName("LevelTutorialFunction") and
			(tutorial:variables():getString("LevelTutorialFunction") ~= "") and
			(gameInfo:getLevelTry(gameInfo:getLevel()) == 1)) then
			if (gameInfo:getLevel() + 1 >= 7) then
				gameInfo:setPassTutorialCount(gameInfo:getPassTutorialCount() + 1)
			end
			if (not gameInfo:getActivePlayerData():findName("FirstPassTutorial")) then
				gameInfo:getActivePlayerData():setBool("FirstPassTutorial", true)
				GUI:getLayer("Game"):getWidget("Game"):AcceptMessage(Message("Pause"))
				if (not gameInfo:getActiveBetaStat():findName("FirstPassTutorialLevel")) then
					gameInfo:getActiveBetaStat():setInt("FirstPassTutorialLevel", gameInfo:getLevel() + 1)
				end
				-- Если отключили подсказки из настроек, то не нужно выводить уведомление, что их можно в настройках включить
				if (not Screen:isLayerOnScreen("Options")) then
					FlyPushLayer("FirstPassTutorial", "FirstPassTutorial", 0)
				else
					TutorialCommonFunction(Message("TutorialPass", "press"))
					tutorial:hide(0.25)
				end
				return
			elseif (gameInfo:getPassTutorialCount() >= 3 and Screen:getMainLayerName() == "Tutorial") then
				GUI:getLayer("Game"):getWidget("Game"):AcceptMessage(Message("Pause"))
				if (not gameInfo:getActiveBetaStat():findName("PassTutorialLevel")) then
					gameInfo:getActiveBetaStat():setInt("PassTutorialLevel", gameInfo:getLevel() + 1)
				end
				FlyPushLayer("PassTutorial", "PassTutorial", 0)
			end
		end
		-- на случай, если был вызван вопрос про выключение туториала
		-- не надо прятать, т.к. спрячется позже
		if (Screen:getMainLayerName() ~= "PassTutorial" and 
			Screen:getMainLayerName() ~= "FirstPassTutorial") then
			tutorial:hide(0.25)
		end
		if (gameInfo:getLevel() == 0) then
			GUI:getLayer("Game"):getWidget("Game"):AcceptMessage(Message("FirstHumanTaskWasGiven"))
		end
		tutorial:variables():eraseName("LevelTutorialFunction")
		TutorialResetFunction();
		--tutorial:reset()
		tutorial:variables():setBool("TutorialPassed", true)
		tutorial:unsetSelected()
		tutorial:variables():setBool("TutorialRentgenEnabled", true) -- чтобы рента генерилась
		tutorial:variables():setBool("TutorialMarketPodstava", false) -- чтобы на рынке стало вновь генериться предложение
		tutorial:variables():eraseName("TutorialGetrentSpeedup")
		tutorial:variables():eraseName("TutorialBuildingSpeedup")
		tutorial:variables():eraseName("TutorialSawmillSpeedup")
		tutorial:variables():eraseName("TutorialUpgradeSpeedup")
		tutorial:variables():eraseName("TutorialArrowsNoBind")
		tutorial:syncJumpWidget("MoneyCount", -1)
		tutorial:syncJumpWidget("MaterialsCount", -1)
		tutorial:syncJumpWidget("WorkersCount", -1)
		tutorial:syncJumpWidget("FoodCount", -1)
		tutorial:syncJumpWidget("HappinessCount", -1)
		tutorial:game():skipTutorial()
		tutorial:variables():setBool("TutorialToSelect", true)
	elseif (message:is("Destroy", "press")) then
		-- Записываем что снесли хоть что-то
		gameInfo:setBoolData("DestroyBuildingPressed", true)
	end
end

function Tutorial_L_1_1_NoHouses(message)
	if (not gameInfo:getActiveBetaStat():findName("Level1NoHousesHint")) then
		gameInfo:getActiveBetaStat():setBool("Level1NoHousesHint", false)
	end
	if (not tutorial:variables():findName("Tutorial_L_1_1_NoHouses")) then
		if (message:is("Update") and tutorial:variables():findName("SmartMoneyStart")
			and not tutorial:variables():getBool("TutorialLock")) then
			if (not tutorial:variables():findName("Tutorial_L_1_1_NoHouses_Time")) then
				tutorial:variables():setFloat("Tutorial_L_1_1_NoHouses_Time", 30.0)
			end
			t = tutorial:variables():getFloat("Tutorial_L_1_1_NoHouses_Time")
			t = t - message:getVariables():getFloat("TimeDelta")
			if (t <= 0.0 and not tutorial:game():isEnded()) then
				tutorial:variables():setBool("Tutorial_L_1_1_NoHouses", true)
				tutorial:variables():setInt("Tutorial_L_1_1_NoHouses_State", 0)
				tutorial:variables():eraseName("Tutorial_L_1_1_NoHouses_Time")
			else
				tutorial:variables():setFloat("Tutorial_L_1_1_NoHouses_Time", t)
			end
		elseif (message:is("House1", "press") and tutorial:variables():findName("SmartMoneyStart")) then
			tutorial:variables():eraseName("Tutorial_L_1_1_NoHouses_Time")
			tutorial:variables():setBool("Tutorial_L_1_1_NoHouses", true)
			tutorial:variables():setInt("Tutorial_L_1_1_NoHouses_State", 2)
		end
	end
	if (tutorial:variables():findName("Tutorial_L_1_1_NoHouses")) then
		if (tutorial:variables():getInt("Tutorial_L_1_1_NoHouses_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isFreeLargeFieldSelected()) then
					textId = "L_1_1_15"
				else
					textId = "L_1_1_14"
				end
				if (tutorial:isShowing()) then
					tutorial:switchText(textId, 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText(textId)
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("Tutorial_L_1_1_NoHouses_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				tutorial:variables():setBool("Clickable", true)
				if (not tutorial:isFreeLargeFieldSelected()) then
					tutorial:targetAllFreeLargeFields(0.5, Point(0, 40), 5.0)
				end
				gameInfo:getActiveBetaStat():setBool("Level1NoHousesHint", true)
			elseif (message:is("House1", "press")) then
				tutorial:variables():eraseName("Tutorial_L_1_1_NoHouses_Time")
				tutorial:variables():setBool("Tutorial_L_1_1_NoHouses", true)
				tutorial:variables():setInt("Tutorial_L_1_1_NoHouses_State", 2)
				tutorial:hideArrows(0.25)
			end
		elseif (tutorial:variables():getInt("Tutorial_L_1_1_NoHouses_State") == 1) then
			if (message:is("House1", "press")) then
				tutorial:variables():setInt("Tutorial_L_1_1_NoHouses_State", 2)
				tutorial:hideArrows(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			elseif (message:is("TutorialOk", "press")) then
				tutorial:variables():eraseName("Tutorial_L_1_1_NoHouses")
				tutorial:variables():eraseName("Tutorial_L_1_1_NoHouses_Time")
				tutorial:variables():setInt("Tutorial_L_1_1_NoHouses_State", 0)
				tutorial:hideArrows(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function Tutorial_L_1_1_HousesBtnHint(message)
	if (not gameInfo:getActiveBetaStat():findName("Level1HousesBtnHint")) then
		gameInfo:getActiveBetaStat():setBool("Level1HousesBtnHint", false)
	end
	if (not tutorial:variables():findName("Tutorial_L_1_1_HousesHint")) then
		if (message:is("Update") and tutorial:variables():findName("SmartMoneyStart")
			and not tutorial:variables():getBool("TutorialLock")) then
			if (not tutorial:variables():findName("Tutorial_L_1_1_HousesHint_Time")) then
				tutorial:variables():setFloat("Tutorial_L_1_1_HousesHint_Time", 5.0)
			end
			if (tutorial:isLargeFieldInterface() and 
				tutorial:variables():findName("HousesHintFieldId") and
				tutorial:variables():getInt("HousesHintFieldId") == tutorial:game():getSelected():id()) then
				t = tutorial:variables():getFloat("Tutorial_L_1_1_HousesHint_Time")
				t = t - message:getVariables():getFloat("TimeDelta")
				if (t <= 0.0 and not tutorial:game():isEnded()) then
					tutorial:variables():setBool("Tutorial_L_1_1_HousesHint", true)
					tutorial:variables():setInt("Tutorial_L_1_1_HousesHint_State", 0)
					tutorial:variables():eraseName("Tutorial_L_1_1_HousesHint_Time")
				else
					tutorial:variables():setFloat("Tutorial_L_1_1_HousesHint_Time", t)
				end
			else
				tutorial:variables():setFloat("Tutorial_L_1_1_HousesHint_Time", 5.0)
				if (tutorial:isLargeFieldInterface()) then
					tutorial:variables():setInt("HousesHintFieldId", tutorial:game():getSelected():id())
				end
			end
		end
	end
	if (tutorial:variables():findName("Tutorial_L_1_1_HousesHint")) then
		if (tutorial:variables():getInt("Tutorial_L_1_1_HousesHint_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_1_1_8", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_1_1_8")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:variables():setFloat("TutorialShowDelayTime", 5.0)
				tutorial:variables():setBool("TutorialArrowsNoBind", true)
				tutorial:show(0.25)
				arrow = tutorial:addArrow()
				tutorial:getArrow(arrow):setPosition(617, 100)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setScale(1.0)
				tutorial:getArrow(arrow):setIgnoreContext(true)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:variables():setFloat("TutorialTextDelayTime", 0.0)
				tutorial:variables():setInt("Tutorial_L_1_1_HousesHint_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				tutorial:variables():setBool("Clickable", true)
				gameInfo:getActiveBetaStat():setBool("Level1HousesBtnHint", true)
			elseif (message:is("Houses", "press")) then
				tutorial:variables():eraseName("Tutorial_L_1_1_HousesHint_Time")
				tutorial:variables():eraseName("Tutorial_L_1_1_HousesHint", true)
				tutorial:variables():setInt("Tutorial_L_1_1_HousesHint_State", 0)
				tutorial:variables():eraseName("TutorialArrowsNoBind")
				tutorial:getArrow(0):setIgnoreContext(false)
			end
		elseif (tutorial:variables():getInt("Tutorial_L_1_1_HousesHint_State") == 1) then
			if (message:is("TutorialOk", "press") or message:is("Houses", "press")) then
				tutorial:getArrow(0):setIgnoreContext(false)
				tutorial:hideArrows(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
				tutorial:variables():eraseName("Tutorial_L_1_1_HousesHint_Time")
				tutorial:variables():eraseName("Tutorial_L_1_1_HousesHint")
				tutorial:variables():eraseName("TutorialArrowsNoBind")
				tutorial:variables():setInt("Tutorial_L_1_1_HousesHint_State", 0)
			end
		end
	end
end

function Tutorial_L_1_1_HouseBtnHint(message)
	if (not gameInfo:getActiveBetaStat():findName("Level1HouseBtnHint")) then
		gameInfo:getActiveBetaStat():setBool("Level1HouseBtnHint", false)
	end
	if (not tutorial:variables():findName("Tutorial_L_1_1_HouseBtnHint")) then
		if (message:is("Update") and tutorial:variables():findName("SmartMoneyStart")
			and not tutorial:variables():getBool("TutorialLock")) then
			if (not tutorial:variables():findName("Tutorial_L_1_1_HouseBtnHint_Time")) then
				tutorial:variables():setFloat("Tutorial_L_1_1_HouseBtnHint_Time", 5.0)
			end
			if (tutorial:isLargeFieldInterfaceHouses() and 
				tutorial:variables():findName("HouseBtnHintFieldId") and
				tutorial:variables():getInt("HouseBtnHintFieldId") == tutorial:game():getSelected():id()) then
				t = tutorial:variables():getFloat("Tutorial_L_1_1_HouseBtnHint_Time")
				t = t - message:getVariables():getFloat("TimeDelta")
				if (t <= 0.0 and not tutorial:game():isEnded()) then
					tutorial:variables():setBool("Tutorial_L_1_1_HouseBtnHint", true)
					tutorial:variables():setInt("Tutorial_L_1_1_HouseBtnHint_State", 0)
					tutorial:variables():eraseName("Tutorial_L_1_1_HouseBtnHint_Time")
				else
					tutorial:variables():setFloat("Tutorial_L_1_1_HouseBtnHint_Time", t)
				end
			else
				tutorial:variables():setFloat("Tutorial_L_1_1_HouseBtnHint_Time", 5.0)
				if (tutorial:isLargeFieldInterfaceHouses()) then
					tutorial:variables():setInt("HouseBtnHintFieldId", tutorial:game():getSelected():id())
				end
			end
		end
	end
	if (tutorial:variables():findName("Tutorial_L_1_1_HouseBtnHint")) then
		if (tutorial:variables():getInt("Tutorial_L_1_1_HouseBtnHint_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_1_1_9", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_1_1_9")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:variables():setFloat("TutorialShowDelayTime", 5.0)
				tutorial:variables():setBool("TutorialArrowsNoBind", true)
				tutorial:show(0.25)
				arrow = tutorial:addArrow()
				tutorial:getArrow(arrow):setPosition(445, 100)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setScale(1.0)
				tutorial:getArrow(arrow):setIgnoreContext(true)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:variables():setFloat("TutorialTextDelayTime", 0.0)
				tutorial:variables():setInt("Tutorial_L_1_1_HouseBtnHint_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				tutorial:variables():setBool("Clickable", true)
				gameInfo:getActiveBetaStat():setBool("Level1HouseBtnHint", true)
			elseif (message:is("House1", "press")) then
				tutorial:variables():eraseName("Tutorial_L_1_1_HouseBtnHint_Time")
				tutorial:variables():eraseName("Tutorial_L_1_1_HouseBtnHint", true)
				tutorial:variables():setInt("Tutorial_L_1_1_HouseBtnHint_State", 0)
				tutorial:variables():eraseName("TutorialArrowsNoBind")
				tutorial:getArrow(0):setIgnoreContext(false)
			end
		elseif (tutorial:variables():getInt("Tutorial_L_1_1_HouseBtnHint_State") == 1) then
			if (message:is("TutorialOk", "press") or message:is("House1", "press")) then
				tutorial:getArrow(0):setIgnoreContext(false)
				tutorial:hideArrows(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
				tutorial:variables():eraseName("Tutorial_L_1_1_HouseBtnHint_Time")
				tutorial:variables():eraseName("Tutorial_L_1_1_HouseBtnHint")
				tutorial:variables():eraseName("TutorialArrowsNoBind")
				tutorial:variables():setInt("Tutorial_L_1_1_HouseBtnHint_State", 0)
			end
		end
	end
end

function L_1_1(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("Tutorial_Smart_Gold")
		tutorial:queueAddMessage("Tutorial_Smart_Money")
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		tutorial:queueAddMessage("Tutorial_L_1_1_NoHouses")
		tutorial:queueAddMessage("Tutorial_L_1_1_HousesBtnHint")
		tutorial:queueAddMessage("Tutorial_L_1_1_HouseBtnHint")
				
		tutorial:show(0.25) -- показать туториал
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:setText("L_1_1_3")
		tutorial:variables():setInt("TutorialState", 3)
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:variables():setBool("TutorialRentgenEnabled", false)
		tutorial:getHouse(1793783):setRentPercent(50)
		tutorial:getHouse(1793790):setRentPercent(85)
		housePos = tutorial:game():getObject(1793789):getScreenPosition()
		arrow = tutorial:addArrow()
		tutorial:getArrow(arrow):setPosition(housePos.x, housePos.y + 70)
		tutorial:getArrow(arrow):setAngle(270)
		housePos = tutorial:game():getObject(1793782):getScreenPosition()
		arrow = tutorial:addArrow()
		tutorial:getArrow(arrow):setPosition(housePos.x, housePos.y + 70)
		tutorial:getArrow(arrow):setAngle(270)
		tutorial:variables():setBool("TutorialGetRentHint", false)
		tutorial:variables():setFloat("MoneyTime", 20.0)
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:addArrow()
		
		tutorial:variables():setBool("TutorialLock", true)
	end	
	if (message:is("LoadLevelFunctionTable") or message:is("LoadLevel")) then
		tutorialFunctionTable[3] = function(message)
			
			if (message:is("TutorialOk", "press")) then
				tutorial:switchText("L_1_1_4", 0.5)
				tutorial:variables():setInt("TutorialState", 4)
				tutorial:variables():setBool("TutorialRentgenEnabled", true)
				tutorial:game():giveFirstCommand()
				tutorial:setWidgetVisible("TutorialOk", false)
			end
		end
		tutorialFunctionTable[4] = function(message)
			if (message:is("RentGenerated")) then
				if (not tutorial:variables():findName("HouseMoney1")) then
					tutorial:variables():setInt("HouseMoney1", message:getIntegerParam())
					tutorial:getArrow(0):show(0.5)
				elseif (not tutorial:variables():findName("HouseMoney2")) then
					tutorial:variables():setInt("HouseMoney2", message:getIntegerParam())
					tutorial:getArrow(1):show(0.5)
				end
			elseif (message:is("RentOrdered")) then
				tutorial:getArrow(0):hide(0.25)
				tutorial:getArrow(1):hide(0.25)
				tutorial:setWidgetVisible("TutorialOk", false)
				tutorial:setWidgetVisible("TutorialWait", true)
				tutorial:switchText("L_1_1_5", 0.5)
				tutorial:variables():setInt("TutorialState", 5)
				tutorial:variables():setBool("TutorialGetrentSpeedup", true)
			end
		end
		tutorialFunctionTable[5] = function(message)
			if (message:is("BackMoney")) then
				tutorial:variables():eraseName("TutorialGetrentSpeedup")
				tutorial:variables():setBool("TutorialKeep", false)
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:setWidgetVisible("TutorialWait", false)
				tutorial:switchText("L_1_1_6", 0.5)
				tutorial:variables():setInt("TutorialState", 7)
				tutorial:getArrow(0):setPosition(129, 725)
				tutorial:getArrow(0):setAngle(90)
				tutorial:getArrow(0):setShowTimer(1.0)
				tutorial:getArrow(0):setScale(1.25)
				tutorial:getArrow(0):show(0.5)
			end
		end
		tutorialFunctionTable[7] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setBool("TutorialKeep", true)
				tutorial:getArrow(0):hide(0.25)
				tutorial:hideContext(0.25)
				tutorial:syncJumpWidget("MoneyCount", -1)
				tutorial:variables():setInt("TutorialState", 8)
			elseif (message:is("ArrowShow")) then
				tutorial:syncJumpWidget("MoneyCount", 0)
			end
		end
		tutorialFunctionTable[8] = function(message)
			if (message:is("TutorialContextHided")) then
				tutorial:variables():setBool("TutorialKeep", false)
				tutorial:variables():setFloat("TutorialContextShowDelayTime", 1.0)
				tutorial:variables():setBool("TutorialArrowAlphaBind", true)
				tutorial:showContext(0.25)
				tutorial:setWidgetVisible("TutorialOk", false)
				tutorial:setText("L_1_1_7")
				fieldPos = tutorial:game():getObject(1793767):getScreenPosition()
				arrow = 2
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 40)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(2.0)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:addObject(1793767)
				fieldPos = tutorial:game():getObject(1793768):getScreenPosition()
				arrow = 3
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 40)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(2.0)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:addObject(1793768)
				fieldPos = tutorial:game():getObject(1793791):getScreenPosition()
				arrow = 4
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 40)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(2.0)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:addObject(1793791)
				tutorial:variables():setBool("TutorialToSelect", true)
			end
			if (message:is("Update")) then
				if (tutorial:game():getSelected()) then
					id = tutorial:game():getSelected():id()
					if (id == 1793767) then
						tutorial:variables():setInt("TutorialActiveArrow", 2)
						tutorial:getArrow(3):hide(0.25)
						tutorial:getArrow(4):hide(0.25)
					elseif (id == 1793768) then
						tutorial:variables():setInt("TutorialActiveArrow", 3)
						tutorial:getArrow(2):hide(0.25)
						tutorial:getArrow(4):hide(0.25)
					elseif (id == 1793791) then
						tutorial:variables():setInt("TutorialActiveArrow", 4)
						tutorial:getArrow(2):hide(0.25)
						tutorial:getArrow(3):hide(0.25)
					end
					tutorial:removeObject(1793767)
					tutorial:removeObject(1793768)
					tutorial:removeObject(1793791)
					tutorial:switchText("L_1_1_8", 0.5)
					tutorial:variables():setBool("TutorialArrowAlphaBind", false)
					tutorial:variables():setBool("TutorialKeepSelection", true)
					tutorial:setSelected()
					tutorial:variables():setInt("TutorialState", 9)
					tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):setIgnoreContext(true)
					tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):moveTo(617, 100, 270, 1.0, 1.0)
					tutorial:addInterfaceButton("Houses")
				end
			end
		end
		tutorialFunctionTable[9] = function(message)
			if (message:is("Houses", "press")) then
				tutorial:switchText("L_1_1_9", 0.5)
				tutorial:setSelected()
				tutorial:variables():setInt("TutorialState", 10)
				tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):stop()
				tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):moveTo(445, 100, 270, 1.0, 0.5)
				tutorial:removeInterfaceButton("Houses")
				tutorial:addInterfaceButton("House1")
			end
		end
		tutorialFunctionTable[10] = function(message)
			if (message:is("House1", "press")) then
				tutorial:switchText("L_1_1_10", 0.5)
				tutorial:variables():setInt("TutorialState", 11)
				tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):hide(0.25)
				tutorial:removeInterfaceButton("House1")
				tutorial:setWidgetVisible("TutorialOk", false)
				tutorial:setWidgetVisible("TutorialWait", true)
				tutorial:variables():setBool("TutorialBuildingSpeedup", true)
			end
		end
		tutorialFunctionTable[11] = function(message)
			if (message:is("BuildingBuilt")) then
				tutorial:variables():eraseName("TutorialBuildingSpeedup")
				tutorial:variables():setBool("TutorialKeep", false)
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:setWidgetVisible("TutorialWait", false)
				tutorial:switchText("L_1_1_11", 0.5)
				tutorial:variables():setInt("TutorialState", 12)
			end
		end
		tutorialFunctionTable[12] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:unsetSelected()
				tutorial:variables():setBool("TutorialKeepSelection", false)
				tutorial:variables():setInt("TutorialState", 13)
				tutorial:variables():setFloat("TutorialContextShowDelayTime", 1.0)
				tutorial:variables():setBool("TutorialArrowAlphaBind", true)
				tutorial:switchText("L_1_1_12", 0.5)
				tutorial:getArrow(0):setPosition(713, 713)
				tutorial:getArrow(0):setAngle(45)
			end
		end
		tutorialFunctionTable[13] = function(message)
			if (message:is("TutorialContextHided")) then
				tutorial:getArrow(0):show(0.5)
				tutorial:getArrow(0):setShowTimer(2.0)
			elseif (message:is("TutorialOk", "press")) then
				tutorial:variables():setBool("TutorialArrowAlphaBind", false)
				tutorial:variables():setInt("TutorialState", 14)
				tutorial:switchText("L_1_1_13", 0.5)
			end
		end
		tutorialFunctionTable[14] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:getArrow(0):hide(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setInt("TutorialState", 20)
				tutorial:variables():setBool("SmartMoneyStart", true)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
	
	if (tutorialFunctionTable[tutorial:variables():getInt("TutorialState")] ~= nil) then
		tutorialFunctionTable[tutorial:variables():getInt("TutorialState")](message)
	end
end


function L_1_2(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("Tutorial_Smart_Gold")
		tutorial:queueAddMessage("Tutorial_Smart_Money")
		tutorial:queueAddMessage("Tutorial_Smart_Materials")
		if (not gameInfo:isDataSet("ExpertTimeHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ExpertTime")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		tutorial:queueAddMessage("Tutorial_Destroy_Sawmill")
					
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_1_2_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:variables():setBool("TutorialNotEnoughMineralsHint", false)
		tutorial:addArrow()
		tutorial:getArrow(0):setPosition(264, 725)
		tutorial:getArrow(0):setAngle(90)
		tutorial:getArrow(0):setShowTimer(3.0)
		tutorial:getArrow(0):setScale(1.25)
		tutorial:getArrow(0):show(0.5)
		
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:addArrow()
		
		tutorial:variables():setBool("TutorialLock", true)
	end	
	if (message:is("LoadLevelFunctionTable") or message:is("LoadLevel")) then	
		tutorialFunctionTable[1] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:switchText("L_1_2_2", 0.5)
				tutorial:variables():setInt("TutorialState", 2)
				
				tutorial:getArrow(0):hide(0.25)
				tutorial:syncJumpWidget("MaterialsCount", -1)
				fieldPos = tutorial:game():getObject(1794128):getScreenPosition()
				arrow = 1
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 40)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(1.5)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:addObject(1794128)
				fieldPos = tutorial:game():getObject(1794129):getScreenPosition()
				arrow = 2
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 40)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(1.5)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:addObject(1794129)
				fieldPos = tutorial:game():getObject(1794147):getScreenPosition()
				arrow = 3
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 40)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(1.5)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:addObject(1794147)
				fieldPos = tutorial:game():getObject(1794162):getScreenPosition()
				arrow = 4
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 40)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(1.5)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:addObject(1794162)
				tutorial:setWidgetVisible("TutorialOk", false)
				tutorial:variables():setBool("TutorialToSelect", true)
			elseif (message:is("ArrowShow")) then
				tutorial:syncJumpWidget("MaterialsCount", 0)
			end
		end
		tutorialFunctionTable[2] = function(message)
			if (message:is("Update")) then
				if (tutorial:game():getSelected()) then
					id = tutorial:game():getSelected():id()
					if (id == 1794128) then
						tutorial:variables():setInt("TutorialActiveArrow", 1)
						tutorial:getArrow(2):hide(0.25)
						tutorial:getArrow(3):hide(0.25)
						tutorial:getArrow(4):hide(0.25)
					elseif (id == 1794129) then
						tutorial:variables():setInt("TutorialActiveArrow", 2)
						tutorial:getArrow(1):hide(0.25)
						tutorial:getArrow(3):hide(0.25)
						tutorial:getArrow(4):hide(0.25)
					elseif (id == 1794147) then
						tutorial:variables():setInt("TutorialActiveArrow", 3)
						tutorial:getArrow(1):hide(0.25)
						tutorial:getArrow(2):hide(0.25)
						tutorial:getArrow(4):hide(0.25)
					elseif (id == 1794162) then
						tutorial:variables():setInt("TutorialActiveArrow", 4)
						tutorial:getArrow(1):hide(0.25)
						tutorial:getArrow(2):hide(0.25)
						tutorial:getArrow(3):hide(0.25)
					end
					tutorial:removeObject(1794128)
					tutorial:removeObject(1794129)
					tutorial:removeObject(1794147)
					tutorial:removeObject(1794162)
					tutorial:switchText("L_1_2_3", 0.5)
					tutorial:variables():setInt("TutorialState", 3)
					tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):moveTo(765, 100, 270, 1.0, 0.5)
					tutorial:addInterfaceButton("Buildings")
					tutorial:variables():setBool("TutorialKeepSelection", true)
					tutorial:setSelected()
				end
			end
		end
		tutorialFunctionTable[3] = function(message)
			if (message:is("Buildings", "press")) then
				tutorial:variables():setInt("TutorialState", 4)
				tutorial:switchText("L_1_2_4", 0.5)
				tutorial:setSelected()
				tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):stop()
				tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):moveTo(495, 100, 270, 1.0, 0.5)
				tutorial:removeInterfaceButton("Buildings")
				tutorial:addInterfaceButton("Sawmill")
			end
		end
		tutorialFunctionTable[4] = function(message)
			if (message:is("Sawmill", "press")) then
				tutorial:variables():setInt("TutorialState", 5)
				tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):hide(0.25)
				tutorial:removeInterfaceButton("Sawmill")
				tutorial:switchText("L_1_2_5", 0.5)
				tutorial:setWidgetVisible("TutorialOk", false)
				tutorial:setWidgetVisible("TutorialWait", true)
				tutorial:variables():setBool("TutorialKeepSelection", false)
				tutorial:variables():setBool("TutorialBuildingSpeedup", true)
			end
		end
		tutorialFunctionTable[5] = function(message)
			if (message:is("BuildingBuilt")) then
				tutorial:variables():eraseName("TutorialBuildingSpeedup")
				tutorial:switchText("L_1_2_6", 0.5)
				tutorial:variables():setInt("TutorialState", 6)
				tutorial:addInterfaceButton("SawmillOffer1")
				tutorial:addInterfaceButton("SawmillOffer2")
				tutorial:addInterfaceButton("SawmillOffer3")
				tutorial:addInterfaceButton("SawmillOffer4")
				tutorial:getArrow(0):stop()
				tutorial:getArrow(0):setCycledMove(false)
				tutorial:getArrow(0):setPosition(540, 100)
				tutorial:getArrow(0):setAngle(270)
				tutorial:getArrow(0):setScale(1.0)
				tutorial:getArrow(0):setShowTimer(1.5)
				--tutorial:getArrow(0):show(0.5)
				tutorial:getArrow(1):stop()
				tutorial:getArrow(1):setCycledMove(false)
				tutorial:getArrow(1):setPosition(640, 100)
				tutorial:getArrow(1):setAngle(270)
				tutorial:getArrow(1):setShowTimer(1.5)
				tutorial:getArrow(1):show(0.5)
				tutorial:getArrow(2):stop()
				tutorial:getArrow(2):setCycledMove(false)
				if (tutorial:game():getVariables().money >= 2000) then
					tutorial:getArrow(2):stop()
					tutorial:getArrow(2):setCycledMove(false)
					tutorial:getArrow(2):setPosition(740, 100)
					tutorial:getArrow(2):setAngle(270)
					tutorial:getArrow(2):setShowTimer(1.5)
					--tutorial:getArrow(2):show(0.5)
				end
				tutorial:setWidgetVisible("TutorialOk", false)
				tutorial:setWidgetVisible("TutorialWait", false)
			end
		end
		tutorialFunctionTable[6] = function(message)
			if (message:is("SawmillOffer1", "press") or
				message:is("SawmillOffer2", "press") or
				message:is("SawmillOffer3", "press") or
				message:is("SawmillOffer4", "press")) then
				tutorial:variables():setInt("TutorialState", 7)
				tutorial:switchText("L_1_2_7", 0.5)
				tutorial:getArrow(0):hide(0.25)
				tutorial:getArrow(1):hide(0.25)
				tutorial:getArrow(2):hide(0.25)
				tutorial:removeInterfaceButton("SawmillOffer1")
				tutorial:removeInterfaceButton("SawmillOffer2")
				tutorial:removeInterfaceButton("SawmillOffer3")
				tutorial:removeInterfaceButton("SawmillOffer4")
				tutorial:setWidgetVisible("TutorialWait", true)
				tutorial:variables():setBool("TutorialSawmillSpeedup", true)
			elseif (message:is("Update")) then
				if (tutorial:game():getVariables().money >= 2000 and
					not tutorial:getArrow(2):isVisible()) then
					tutorial:getArrow(2):stop()
					tutorial:getArrow(2):setCycledMove(false)
					tutorial:getArrow(2):setPosition(740, 100)
					tutorial:getArrow(2):setAngle(270)
					--tutorial:getArrow(2):setShowTimer(1.5)
					--tutorial:getArrow(2):show(0.5)
					tutorial:getArrow(2):copyTime(tutorial:getArrow(1))
				end
			end
		end
		tutorialFunctionTable[7] = function(message)
			if (message:is("BackMaterials")) then
				tutorial:variables():eraseName("TutorialSawmillSpeedup")
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:setWidgetVisible("TutorialWait", false)
				tutorial:switchText("L_1_2_8", 0.5)
				tutorial:variables():setInt("TutorialState", 8)
			end
		end
		tutorialFunctionTable[8] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 9)
				tutorial:unsetSelected()
				tutorial:variables():setBool("TutorialKeepSelection", false)
				tutorial:hide(0.25)
				tutorial:variables():setBool("SmartMoneyStart", true)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
	
	if (tutorialFunctionTable[tutorial:variables():getInt("TutorialState")] ~= nil) then
		tutorialFunctionTable[tutorial:variables():getInt("TutorialState")](message)
	end
end


function Tutorial_L_1_3_SawmillHint(message)
	if (not gameInfo:getActiveBetaStat():findName("Level3SawmillHint")) then
		gameInfo:getActiveBetaStat():setBool("Level3SawmillHint", false)
	end
	if (not tutorial:variables():findName("Tutorial_L_1_3_SawmillHint")) then
		if (message:is("Update") and tutorial:game():getVariables().materials == 10
			and not tutorial:variables():getBool("TutorialLock")
			and tutorial:game():isFirstCommandWasGiven()) then
			if (not tutorial:variables():findName("Tutorial_L_1_3_SawmillHint_Time")) then
				tutorial:variables():setFloat("Tutorial_L_1_3_SawmillHint_Time", 30.0)
			end
			t = tutorial:variables():getFloat("Tutorial_L_1_3_SawmillHint_Time")
			t = t - message:getVariables():getFloat("TimeDelta")
			if (t <= 0.0 and not tutorial:game():isEnded()) then
				tutorial:variables():setBool("Tutorial_L_1_3_SawmillHint", true)
				tutorial:variables():setInt("Tutorial_L_1_3_SawmillHint_State", 0)
				tutorial:variables():eraseName("Tutorial_L_1_3_SawmillHint_Time")
			else
				tutorial:variables():setFloat("Tutorial_L_1_3_SawmillHint_Time", t)
			end
		elseif (message:is("Sawmill", "press")) then
			tutorial:variables():setBool("Tutorial_L_1_3_SawmillHint", true)
			tutorial:variables():setInt("Tutorial_L_1_3_SawmillHint_State", 2)
		end
	end
	if (tutorial:variables():findName("Tutorial_L_1_3_SawmillHint")) then
		if (tutorial:variables():getInt("Tutorial_L_1_3_SawmillHint_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_1_3_7", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_1_3_7")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setFloat("TutorialTextDelayTime", 0.0)
				tutorial:variables():setInt("Tutorial_L_1_3_SawmillHint_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				tutorial:variables():setBool("Clickable", true)
				gameInfo:getActiveBetaStat():setBool("Level3SawmillHint", true)
			elseif (message:is("Sawmill", "press")) then
				tutorial:variables():setBool("Tutorial_L_1_3_SawmillHint", true)
				tutorial:variables():setInt("Tutorial_L_1_3_SawmillHint_State", 2)
			end
		elseif (tutorial:variables():getInt("Tutorial_L_1_3_SawmillHint_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
				tutorial:variables():eraseName("Tutorial_L_1_3_SawmillHint_Time")
				tutorial:variables():eraseName("Tutorial_L_1_3_SawmillHint")
				tutorial:variables():setInt("Tutorial_L_1_3_SawmillHint_State", 0)
			elseif (message:is("Sawmill", "press")) then
				tutorial:hide(0.25)
				tutorial:variables():setBool("Tutorial_L_1_3_SawmillHint", true)
				tutorial:variables():setInt("Tutorial_L_1_3_SawmillHint_State", 2)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end


function L_1_3(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("Tutorial_Smart_Money_All")
		tutorial:queueAddMessage("Tutorial_Smart_Materials_All")
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		tutorial:queueAddMessage("Tutorial_L_1_3_SawmillHint")
		tutorial:queueAddMessage("Tutorial_Destroy_Sawmill")
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:setText("L_1_3_2")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:variables():setInt("TutorialState", 2)
		
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:variables():setBool("TutorialLock", true)
	end	
	if (message:is("LoadLevelFunctionTable") or message:is("LoadLevel")) then	
		tutorialFunctionTable[2] = function(message)
			
			if (message:is("TutorialOk", "press")) then
				fieldPos = tutorial:game():getObject(1794543):getScreenPosition()
				arrow = 0
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 40)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(1.5)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:addObject(1794543)
				fieldPos = tutorial:game():getObject(1794548):getScreenPosition()
				arrow = 1
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 40)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(1.5)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:addObject(1794548)
				tutorial:switchText("L_1_3_3", 0.5)
				tutorial:setWidgetVisible("TutorialOk", false)
				tutorial:variables():setInt("TutorialState", 3)
				tutorial:variables():setBool("TutorialToSelect", true)
			end
		end
		tutorialFunctionTable[3] = function(message)
			if (message:is("Update")) then
				if (tutorial:game():getSelected()) then
					id = tutorial:game():getSelected():id()
					if (id == 1794543) then
						tutorial:variables():setInt("TutorialActiveArrow", 0)
						tutorial:getArrow(1):hide(0.25)
					elseif (id == 1794548) then
						tutorial:variables():setInt("TutorialActiveArrow", 1)
						tutorial:getArrow(0):hide(0.25)
					end
					tutorial:removeObject(1794543)
					tutorial:removeObject(1794548)
					tutorial:variables():setInt("TutorialState", 4)
					tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):moveTo(640, 100, 270, 1.0, 0.5)
					tutorial:addInterfaceButton("Upgrade")
					tutorial:switchText("L_1_3_4", 0.5)
					tutorial:variables():setBool("TutorialKeepSelection", true)
					tutorial:setSelected()
				end
			end
		end
		tutorialFunctionTable[4] = function(message)
			if (message:is("Upgrade", "press")) then
				tutorial:variables():setInt("TutorialState", 5)
				tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):hide(0.25)
				tutorial:removeInterfaceButton("Upgrade")
				tutorial:switchText("L_1_3_5", 0.5)
				tutorial:setWidgetVisible("TutorialWait", true)
				tutorial:variables():setBool("TutorialUpgradeSpeedup", true)
			end
		end
		tutorialFunctionTable[5] = function(message)
			if (message:is("BuildingUpgrade")) then
				tutorial:variables():eraseName("TutorialUpgradeSpeedup")
				tutorial:switchText("L_1_3_6", 0.5)
				tutorial:variables():setInt("TutorialState", 6)
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:setWidgetVisible("TutorialWait", false)
			end
		end
		tutorialFunctionTable[6] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 7)
				tutorial:hide(0.25)
				tutorial:unsetSelected()
				tutorial:variables():setBool("TutorialKeepSelection", false)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
	
	if (tutorialFunctionTable[tutorial:variables():getInt("TutorialState")] ~= nil) then
		tutorialFunctionTable[tutorial:variables():getInt("TutorialState")](message)
	end
end


function Tutorial_L_2_1_JunkHint(message)
	if (not gameInfo:getActiveBetaStat():findName("Level4JunkHint")) then
		gameInfo:getActiveBetaStat():setBool("Level4JunkHint", false)
	end
	if (not tutorial:variables():findName("Tutorial_L_2_1_JunkHint")) then
		if (message:is("Update") and not tutorial:variables():getBool("TutorialLock") and tutorial:game():isFirstCommandWasGiven()) then
			if (not tutorial:variables():findName("Tutorial_L_2_1_JunkHint_Time")) then
				tutorial:variables():setFloat("Tutorial_L_2_1_JunkHint_Time", 40.0)
			end
			t = tutorial:variables():getFloat("Tutorial_L_2_1_JunkHint_Time")
			t = t - message:getVariables():getFloat("TimeDelta")
			if (t <= 0.0 and not tutorial:game():isEnded()) then
				tutorial:variables():setBool("Tutorial_L_2_1_JunkHint", true)
				tutorial:variables():setInt("Tutorial_L_2_1_JunkHint_State", 0)
				tutorial:variables():eraseName("Tutorial_L_2_1_JunkHint_Time")
			else
				tutorial:variables():setFloat("Tutorial_L_2_1_JunkHint_Time", t)
			end
		elseif (message:is("Bridge2", "press") and tutorial:variables():getInt("TutorialState") >= 3) then
			-- первый раз жмём в туториале
			if (not tutorial:variables():findName("Tutorial_L_2_1_Bridge2Button")) then
				tutorial:variables():setBool("Tutorial_L_2_1_Bridge2Button", true)
			else
				tutorial:variables():setBool("Tutorial_L_2_1_JunkHint", true)
				tutorial:variables():setInt("Tutorial_L_2_1_JunkHint_State", 2)
			end
		end
	end
	if (tutorial:variables():findName("Tutorial_L_2_1_JunkHint")) then
		if (tutorial:variables():getInt("Tutorial_L_2_1_JunkHint_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_2_1_4", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_2_1_4")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setFloat("TutorialTextDelayTime", 0.0)
				tutorial:variables():setInt("Tutorial_L_2_1_JunkHint_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				tutorial:variables():setBool("Clickable", true)
				
				fieldPos = tutorial:game():getObject(2520019):getScreenPosition()
				arrow = tutorial:addArrow()
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setScale(1.0)
				tutorial:getArrow(arrow):setShowTimer(2.5)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 0)
				
				gameInfo:getActiveBetaStat():setBool("Level4JunkHint", true)
			elseif (message:is("Bridge2", "press")) then
				tutorial:variables():setBool("Tutorial_L_2_1_JunkHint", true)
				tutorial:variables():setInt("Tutorial_L_2_1_JunkHint_State", 2)
			end
		elseif (tutorial:variables():getInt("Tutorial_L_2_1_JunkHint_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:hideArrows(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
				tutorial:variables():eraseName("Tutorial_L_2_1_JunkHint_Time")
				tutorial:variables():eraseName("Tutorial_L_2_1_JunkHint")
				tutorial:variables():setInt("Tutorial_L_2_1_JunkHint_State", 0)
			elseif (message:is("Bridge2", "press")) then
				tutorial:hideArrows(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("Tutorial_L_2_1_JunkHint", true)
				tutorial:variables():setInt("Tutorial_L_2_1_JunkHint_State", 2)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_2_1(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("Tutorial_Smart_Money_All")
		tutorial:queueAddMessage("Tutorial_Smart_Materials_All")
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("MoneyLostHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoneyLost")
		end
		tutorial:queueAddMessage("Tutorial_L_2_1_JunkHint")
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 0)
		
		scale = 0.7
		fieldPos = tutorial:game():getObject(2520019):getScreenPosition()
		arrow = tutorial:addArrow()
		tutorial:getArrow(arrow):setAngle(270)
		tutorial:getArrow(arrow):setScale(scale)
		tutorial:getArrow(arrow):setShowTimer(2.5)
		tutorial:getArrow(arrow):show(0.5)
		tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 0)
		fieldPos = tutorial:game():getObject(2520021):getScreenPosition()
		arrow = tutorial:addArrow()
		tutorial:getArrow(arrow):setAngle(270)
		tutorial:getArrow(arrow):setScale(scale)
		tutorial:getArrow(arrow):setShowTimer(2.5)
		tutorial:getArrow(arrow):show(0.5)
		tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 0)
		fieldPos = tutorial:game():getObject(2520096):getScreenPosition()
		arrow = tutorial:addArrow()
		tutorial:getArrow(arrow):setAngle(270)
		tutorial:getArrow(arrow):setScale(scale)
		tutorial:getArrow(arrow):setShowTimer(2.5)
		tutorial:getArrow(arrow):show(0.5)
		tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 0)
		fieldPos = tutorial:game():getObject(2520102):getScreenPosition()
		arrow = tutorial:addArrow()
		tutorial:getArrow(arrow):setAngle(270)
		tutorial:getArrow(arrow):setScale(scale)
		tutorial:getArrow(arrow):setShowTimer(2.5)
		tutorial:getArrow(arrow):show(0.5)
		tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 0)
		fieldPos = tutorial:game():getObject(2520104):getScreenPosition()
		arrow = tutorial:addArrow()
		tutorial:getArrow(arrow):setAngle(270)
		tutorial:getArrow(arrow):setScale(scale)
		tutorial:getArrow(arrow):setShowTimer(2.5)
		tutorial:getArrow(arrow):show(0.5)
		tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 0)
		arrow = tutorial:addArrow()
		arrow = tutorial:addArrow()
		
		tutorial:setText("L_2_1_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		
		tutorial:variables():setBool("TutorialLock", true)
	end	
	if (message:is("LoadLevelFunctionTable") or message:is("LoadLevel")) then	
		tutorialFunctionTable[0] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 1)
				tutorial:getArrow(0):hide(0.25)
				tutorial:getArrow(1):hide(0.25)
				tutorial:getArrow(2):hide(0.25)
				tutorial:getArrow(3):hide(0.25)
				tutorial:getArrow(4):hide(0.25)
				tutorial:getArrow(5):hide(0.25)
				tutorial:switchText("L_2_1_2", 0.5)
				tutorial:setWidgetVisible("TutorialOk", false)
				fieldPos = tutorial:game():getObject(2520021):getScreenPosition()
				tutorial:getArrow(6):setPosition(fieldPos.x, fieldPos.y + 20)
				tutorial:getArrow(6):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(1.5)
				tutorial:getArrow(6):show(0.5)
				tutorial:addObject(2520021)
				tutorial:variables():setBool("TutorialToSelect", true)
			end
		end
		tutorialFunctionTable[1] = function(message)
			if (message:is("Update")) then
				if (tutorial:game():getSelected()) then
					id = tutorial:game():getSelected():id()
					tutorial:removeObject(2520021)
					tutorial:switchText("L_2_1_3", 0.5)
					tutorial:variables():setInt("TutorialState", 2)
					tutorial:getArrow(6):moveTo(705, 100, 270, 1.0, 0.5)
					tutorial:addInterfaceButton("Bridge2")
					tutorial:variables():setBool("TutorialKeepSelection", true)
					tutorial:setSelected()
				end
			end
		end
		tutorialFunctionTable[2] = function(message)
			if (message:is("Bridge2", "press")) then
				tutorial:variables():setInt("TutorialState", 3)
				tutorial:variables():setBool("TutorialKeepSelection", false)
				tutorial:unsetSelected()
				tutorial:getArrow(6):hide(0.5)
				tutorial:removeInterfaceButton("Bridge2")
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
	if (tutorialFunctionTable[tutorial:variables():getInt("TutorialState")] ~= nil) then
		tutorialFunctionTable[tutorial:variables():getInt("TutorialState")](message)
	end
end

function L_2_2_Foundry1(message)
	if (not tutorial:variables():findName("L_2_2_Foundry1") and message:is("FoundryStart")) then
		tutorial:variables():setBool("L_2_2_Foundry1", true)
		tutorial:variables():setInt("L_2_2_Foundry1_State", 0)
	end
	if (tutorial:variables():findName("L_2_2_Foundry1")) then
		if (tutorial:variables():getInt("L_2_2_Foundry1_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_2_2_6", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_2_2_6")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_2_2_Foundry1_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
			end
		elseif (tutorial:variables():getInt("L_2_2_Foundry1_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_2_2_Foundry1_State", 2)
				tutorial:hide(0.25)
				tutorial:queueAddMessage("L_2_2_Foundry2")
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_2_2_Foundry2(message)
	if (not tutorial:variables():findName("L_2_2_Foundry2") and message:is("FoundryStart")) then
		tutorial:variables():setBool("L_2_2_Foundry2", true)
		tutorial:variables():setInt("L_2_2_Foundry2_State", 0)
	end
	if (tutorial:variables():findName("L_2_2_Foundry2")) then
		if (tutorial:variables():getInt("L_2_2_Foundry2_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_2_2_8", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_2_2_8")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_2_2_Foundry2_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
			end
		elseif (tutorial:variables():getInt("L_2_2_Foundry2_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_2_2_Foundry2_State", 2)
				tutorial:hide(0.25)
				--tutorial:queueAddMessage("L_2_2_Foundry3")
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_2_2_Foundry3(message)
	if (not tutorial:variables():findName("L_2_2_Foundry3") and message:is("FoundryStart")) then
		tutorial:variables():setBool("L_2_2_Foundry3", true)
		tutorial:variables():setInt("L_2_2_Foundry3_State", 0)
	end
	if (tutorial:variables():findName("L_2_2_Foundry3")) then
		if (tutorial:variables():getInt("L_2_2_Foundry3_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_2_2_8", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_2_2_8")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_2_2_Foundry3_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
			end
		elseif (tutorial:variables():getInt("L_2_2_Foundry3_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_2_2_Foundry3_State", 2)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_2_2(message)
	foundryId = 1795082
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("L_2_2_Foundry1")
		tutorial:queueAddMessage("Tutorial_Smart_Materials_All")
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		if (not gameInfo:isDataSet("MoneyLostHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoneyLost")
		end
		tutorial:queueAddMessage("Tutorial_Smart_Workers")
				
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_2_2_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:addArrow()
		tutorial:getArrow(0):setPosition(885, 434)
		tutorial:getArrow(0):setAngle(90)
		tutorial:getArrow(0):setShowTimer(2.5)
		tutorial:getArrow(0):show(0.5)
		tutorial:addArrow()
		tutorial:getArrow(1):setPosition(397, 725)
		tutorial:getArrow(1):setAngle(90)
		
		tutorial:variables():setBool("TutorialLock", true)
	end	
	if (message:is("LoadLevelFunctionTable") or message:is("LoadLevel")) then	
		tutorialFunctionTable[1] = function(message)
			
			if (message:is("TutorialOk", "press")) then
				tutorial:switchText("L_2_2_2", 0.5)
				tutorial:variables():setInt("TutorialState", 2)
			end
		end
		tutorialFunctionTable[2] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 3)
				tutorial:getArrow(0):hide(0.25)
				--tutorial:hide(0.25)
				--tutorial:variables():setBool("TutorialToSelect", true)
				tutorial:hideContext(0.25)
			end
		end
		tutorialFunctionTable[3] = function(message)
			if (message:is("TutorialContextHided")) then
				tutorial:variables():setBool("TutorialKeep", false)
				tutorial:variables():setFloat("TutorialContextShowDelayTime", 1.0)
				--tutorial:variables():setBool("TutorialArrowAlphaBind", true)
				tutorial:showContext(0.25)
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:setText("L_2_2_3")
				tutorial:getArrow(1):setShowTimer(2.5)
				tutorial:getArrow(1):setScale(1.25)
				tutorial:getArrow(1):show(0.5)
				tutorial:variables():setInt("TutorialState", 4)
			end
		end
		tutorialFunctionTable[4] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:switchText("L_2_2_4", 0.5)
				tutorial:setWidgetVisible("TutorialOk", false)
				--tutorial:getArrow(1):setCycledMove(false)
				--tutorial:getArrow(1):stop()
				tutorial:syncJumpWidget("WorkersCount", -1)
				fieldPos = tutorial:game():getObject(1795079):getScreenPosition()
				--tutorial:getArrow(1):setIgnoreContext(true)
				tutorial:getArrow(1):moveTo(fieldPos.x, fieldPos.y + 40, 270, 1.0, 0.5)
				tutorial:addObject(1795079)
				tutorial:variables():setBool("TutorialToSelect", true)
			elseif (message:is("ArrowShow")) then
				if (not tutorial:variables():getBool("TutorialToSelect")) then
					tutorial:syncJumpWidget("WorkersCount", 1)
				end
			end
			if (message:is("Update")) then
				if (tutorial:game():getSelected()) then
					tutorial:removeObject(1795079)
					tutorial:syncJumpWidget("WorkersCount", -1)
					tutorial:switchText("L_2_2_5", 0.5)
					tutorial:variables():setBool("TutorialArrowAlphaBind", false)
					tutorial:variables():setBool("TutorialKeepSelection", true)
					tutorial:setSelected()
					tutorial:variables():setInt("TutorialState", 5)
					tutorial:getArrow(1):moveTo(617, 100, 270, 1.0, 1.0)
					tutorial:addInterfaceButton("Worker")
				end
			end
		end
		tutorialFunctionTable[5] = function(message)
			if (message:is("Worker", "press")) then
				tutorial:variables():setInt("TutorialState", 6)
				tutorial:getArrow(1):hide(0.25)
				tutorial:removeInterfaceButton("Worker")
				tutorial:hide(0.25)
				tutorial:unsetSelected()
				tutorial:variables():setBool("TutorialKeepSelection", false)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
	
	if (tutorialFunctionTable[tutorial:variables():getInt("TutorialState")] ~= nil) then
		tutorialFunctionTable[tutorial:variables():getInt("TutorialState")](message)
	end
end

function L_2_3_House2(message)
	if (not tutorial:variables():findName("L_2_3_House2") and message:is("BuildingBuilt") and message:getVariables():getInt("Type") == HouseType and 
				message:getVariables():getInt("HouseType") == 1) then
		tutorial:variables():setBool("L_2_3_House2", true)
		tutorial:variables():setInt("L_2_3_House2_State", 0)
	end
	if (tutorial:variables():findName("L_2_3_House2")) then
		if (tutorial:variables():getInt("L_2_3_House2_State") == 0) then
			tutorial:variables():setFloat("L_2_3_TutorialDestroyTime", 10.0)
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_2_3_4", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_2_3_4")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_2_3_House2_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
			end
		elseif (tutorial:variables():getInt("L_2_3_House2_State") == 1) then
			tutorial:variables():setFloat("L_2_3_TutorialDestroyTime", 10.0)
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_2_3_House2_State", 2)
				tutorial:variables():setBool("L_2_3_House2Showed", true)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_2_3_Destroy(message)
	if (not gameInfo:getActiveBetaStat():findName("DestroyHint")) then
		gameInfo:getActiveBetaStat():setBool("DestroyHint", false)
	end
	if (not tutorial:variables():findName("L_2_3_Destroy") and tutorial:game():getFreeFieldsCount() == 0 and
		not tutorial:variables():getBool("TutorialWasDestroy") and message:is("Update")) then
		if (not tutorial:variables():findName("L_2_3_TutorialDestroyTime")) then
			tutorial:variables():setFloat("L_2_3_TutorialDestroyTime", 20.0)
		end
		tutorial:variables():setFloat("L_2_3_TutorialDestroyTime", tutorial:variables():getFloat("L_2_3_TutorialDestroyTime") - message:getVariables():getFloat("TimeDelta"))
		if (tutorial:variables():getFloat("L_2_3_TutorialDestroyTime") < 0.0) then
			tutorial:variables():setInt("L_2_3_Destroy_Ready", 1)
		end
	end
	if (tutorial:variables():findName("L_2_3_Destroy_Ready")) then
		tutorial:variables():setBool("L_2_3_Destroy", true)
		tutorial:variables():setInt("L_2_3_Destroy_State", 0)
		tutorial:variables():eraseName("L_2_3_Destroy_Ready")
	end
	if (tutorial:variables():findName("L_2_3_Destroy")) then
		if (tutorial:variables():getInt("L_2_3_Destroy_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					if (tutorial:variables():findName("L_2_3_House2Showed")) then
						tutorial:switchText("L_2_3_5", 0.5)
					else
						tutorial:switchText("L_2_3_5_House1", 0.5)
					end
					tutorial:switchCharacter("Sedrik")
				else
					if (tutorial:variables():findName("L_2_3_House2Showed")) then
						tutorial:setText("L_2_3_5")
					else
						tutorial:setText("L_2_3_5_House1")
					end
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_2_3_Destroy_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				gameInfo:getActiveBetaStat():setBool("DestroyHint", true)
			end
		elseif (tutorial:variables():getInt("L_2_3_Destroy_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				
				tutorial:variables():setInt("L_2_3_Destroy_State", 2)
				tutorial:switchText("L_2_3_6", 0.5)
				tutorial:setWidgetVisible("TutorialOk", false)
				tutorial:clearSelection()
				tutorial:targetAllHouses(0, 0.5, Point(0, 40), 1.5)
			end
		elseif (tutorial:variables():getInt("L_2_3_Destroy_State") == 2) then
			if (message:is("Update")) then
				if (tutorial:game():getSelected()) then
					id = tutorial:game():getSelected():id()
					tutorial:hideArrows(0.5)
					tutorial:variables():setInt("TutorialActiveArrow", tutorial:getHouseArrow(0, id))
					tutorial:variables():setInt("L_2_3_DestroyHouseId", id)
					if (tutorial:getHouseByField(id):isUpgrading()) then
						tutorial:variables():setInt("L_2_3_Destroy_State", 3)
						tutorial:setWidgetVisible("TutorialOk", false)
						tutorial:setWidgetVisible("TutorialWait", true)
						tutorial:switchText("L_2_3_5_HouseUpgrade", 0.5)
					else
						tutorial:variables():setInt("L_2_3_Destroy_State", 5)
						tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):moveTo(950, 100, 270, 1.0, 0.5)
						tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):setShown()
						--tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):show(0.5)
						tutorial:addInterfaceButton("Destroy")
						tutorial:switchText("L_2_3_7", 0.5)
					end
					tutorial:variables():setBool("TutorialKeepSelection", true)
					tutorial:setSelected()
				end
			end
		elseif (tutorial:variables():getInt("L_2_3_Destroy_State") == 3) then
			if (message:is("Update") and not tutorial:getHouseByField(tutorial:variables():getInt("L_2_3_DestroyHouseId")):isUpgrading()) then
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:setWidgetVisible("TutorialWait", false)
				tutorial:variables():setInt("L_2_3_Destroy_State", 5)
				tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):moveTo(950, 100, 270, 1.0, 0.5)
				tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):setShown()
				--tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):show(0.5)
				tutorial:addInterfaceButton("Destroy")
				tutorial:switchText("L_2_3_7", 0.5)
			end
		elseif (tutorial:variables():getInt("L_2_3_Destroy_State") == 5) then
			if (message:is("Destroy", "press")) then
				tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):hide(0.25)
				tutorial:removeInterfaceButton("Destroy")
				tutorial:variables():setBool("TutorialKeepSelection", false)
				tutorial:unsetSelected()
				tutorial:variables():setInt("L_2_3_Destroy_State", 6)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
	
	if (message:is("Destroy", "press")) then
		tutorial:variables():setBool("TutorialWasDestroy", true)
	end
end

function L_2_3(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("L_2_3_House2")
		tutorial:queueAddMessage("L_2_3_Destroy")
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		if (not gameInfo:isDataSet("MoneyLostHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoneyLost")
		end
		
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_2_3_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:variables():setBool("TutorialWasDestroy", false)
		
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:addArrow()
		
		tutorial:variables():setBool("TutorialLock", true)
	end	
	if (message:is("LoadLevelFunctionTable") or message:is("LoadLevel")) then	
		tutorialFunctionTable[1] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:switchText("L_2_3_3", 0.5)
				tutorial:variables():setInt("TutorialState", 3)
			end
		end
		tutorialFunctionTable[3] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 4)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialToSelect", true)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
	
	if (tutorialFunctionTable[tutorial:variables():getInt("TutorialState")] ~= nil) then
		tutorialFunctionTable[tutorial:variables():getInt("TutorialState")](message)
	end
end

function L_2_4_Market(message)
	if (not tutorial:variables():findName("L_2_4_Market") and message:is("BuildingBuilt") and message:getVariables():getInt("Type") == MarketType) then
		tutorial:variables():setBool("L_2_4_Market", true)
		tutorial:variables():setInt("L_2_4_Market_State", 0)
		tutorial:variables():setInt("TutorialMarketId", message:getIntegerParam())
	end
	if (tutorial:variables():findName("L_2_4_Market")) then
		if (tutorial:variables():getInt("L_2_4_Market_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_2_4_2", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_2_4_2")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_2_4_Market_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
			end
		elseif (tutorial:variables():getInt("L_2_4_Market_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_2_4_Market_State", 2)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_2_4_MarketOrder(message)
	if (message:is("MarketOrder")) then
		tutorial:variables():setBool("L_2_4_MarketOrder", true)
		tutorial:variables():setInt("L_2_4_MarketOrder_State", 4)
	end
	if (not tutorial:variables():findName("L_2_4_MarketOrder") and message:is("Update")) then
		if ((tutorial:game():getVariables().materials >= 20) and tutorial:game():getMarketId() >= 0) then
			tutorial:variables():setBool("L_2_4_MarketOrder", true)
			tutorial:variables():setInt("L_2_4_MarketOrder_State", 0)
			tutorial:variables():setInt("TutorialMarketId", tutorial:game():getMarketId())
		end
	end
	if (tutorial:variables():findName("L_2_4_MarketOrder")) then
		if (tutorial:variables():getInt("L_2_4_MarketOrder_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:game():getSelected() and tutorial:game():getSelected():id() == tutorial:variables():getInt("TutorialMarketId")) then
					if (tutorial:isShowing()) then
						tutorial:switchText("L_2_4_4", 0.5)
						tutorial:switchCharacter("Sedrik")
					else
						tutorial:setText("L_2_4_4")
						tutorial:setCharacter("Sedrik")
					end
					tutorial:variables():setInt("L_2_4_MarketOrder_State", 2)
					tutorial:variables():setBool("TutorialKeepSelection", true)
					tutorial:addInterfaceButton("MarketOffer2")
					tutorial:setWidgetVisible("TutorialOk", false)
					tutorial:setSelected()
				else
					if (tutorial:isShowing()) then
						tutorial:switchText("L_2_4_3", 0.5)
						tutorial:switchCharacter("Sedrik")
					else
						tutorial:setText("L_2_4_3")
						tutorial:setCharacter("Sedrik")
					end
					tutorial:variables():setInt("L_2_4_MarketOrder_State", 1)
					fieldPos = tutorial:game():getObject(tutorial:variables():getInt("TutorialMarketId")):getScreenPosition()
					arrow = 0
					tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 40)
					tutorial:getArrow(arrow):setAngle(270)
					tutorial:getArrow(arrow):setShowTimer(1.5)
					tutorial:getArrow(arrow):show(0.5)
					tutorial:clearSelection()
					tutorial:addObject(tutorial:variables():getInt("TutorialMarketId"))
					tutorial:setWidgetVisible("TutorialOk", false)
				end
				tutorial:show(0.25)
				tutorial:variables():setBool("TutorialLock", true)
			end
		elseif (tutorial:variables():getInt("L_2_4_MarketOrder_State") == 1) then
			if (message:is("Update")) then
				if (tutorial:game():getSelected() and tutorial:game():getSelected():id() == tutorial:variables():getInt("TutorialMarketId")) then
					id = tutorial:game():getSelected():id()
					tutorial:variables():setInt("L_2_4_MarketOrder_State", 2)
					--tutorial:getArrow(0):moveTo(640, 100, 270, 1.0, 0.5)
					tutorial:getArrow(0):hide(0.5)
					tutorial:addInterfaceButton("MarketOffer2")
					tutorial:variables():setBool("TutorialKeepSelection", true)
					tutorial:setWidgetVisible("TutorialOk", false)
					tutorial:switchText("L_2_4_4", 0.5)
					tutorial:setSelected()
				end
			end
		elseif (tutorial:variables():getInt("L_2_4_MarketOrder_State") == 2) then
			if (message:is("MarketOffer2", "press")) then
				tutorial:getArrow(0):hide(0.5)
				tutorial:getArrow(1):hide(0.5)
				tutorial:variables():setBool("TutorialMarketPodstava", false)
				tutorial:variables():setInt("L_2_4_MarketOrder_State", 3)
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:unsetSelected()
				tutorial:variables():setBool("TutorialKeepSelection", false)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			elseif (message:is("Update")) then
				marker = tutorial:variables():getFloat("MarketMarker")
				if (marker > 0.0) then
					marker = marker - message:getVariables():getFloat("TimeDelta")
					if (marker <= 0.0) then
						arrow = 1
						tutorial:getArrow(arrow):setPosition(640, 100)
						tutorial:getArrow(arrow):setAngle(270)
						tutorial:getArrow(arrow):show(0.5)
					end
					tutorial:variables():setFloat("MarketMarker", marker)
				end
			end
		elseif (tutorial:variables():getInt("L_2_4_MarketOrder_State") == 4) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_2_4_MarketOrder_State", 5)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function Tutorial_L_2_4_MarketHint(message)
	if (not gameInfo:getActiveBetaStat():findName("Level7MarketHint")) then
		gameInfo:getActiveBetaStat():setBool("Level7MarketHint", false)
	end
	if (not tutorial:variables():findName("Tutorial_L_2_4_MarketHint")) then
		if (message:is("Update") and (not tutorial:variables():getBool("TutorialLock"))
			and tutorial:variables():findName("Tutorial_L_2_4_MarketButton")) then
			if (not tutorial:variables():findName("Tutorial_L_2_4_MarketHint_Time")) then
				tutorial:variables():setFloat("Tutorial_L_2_4_MarketHint_Time", 70.0)
			end
			t = tutorial:variables():getFloat("Tutorial_L_2_4_MarketHint_Time")
			t = t - message:getVariables():getFloat("TimeDelta")
			if (t <= 0.0 and not tutorial:game():isEnded()) then
				tutorial:variables():setBool("Tutorial_L_2_4_MarketHint", true)
				tutorial:variables():setInt("Tutorial_L_2_4_MarketHint_State", 0)
				tutorial:variables():eraseName("Tutorial_L_2_4_MarketHint_Time")
			else
				tutorial:variables():setFloat("Tutorial_L_2_4_MarketHint_Time", t)
			end
		elseif (message:is("Market", "press")) then
			-- первый раз пропускаем, нам нужен второй рынок
			if (not tutorial:variables():findName("Tutorial_L_2_4_MarketButton")) then
				tutorial:variables():setBool("Tutorial_L_2_4_MarketButton", true)
			else
				tutorial:variables():setBool("Tutorial_L_2_4_MarketHint", true)
				tutorial:variables():setInt("Tutorial_L_2_4_MarketHint_State", 2)
			end
		end
	end
	if (tutorial:variables():findName("Tutorial_L_2_4_MarketHint")) then
		if (tutorial:variables():getInt("Tutorial_L_2_4_MarketHint_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_2_4_5", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_2_4_5")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setFloat("TutorialTextDelayTime", 0.0)
				tutorial:variables():setInt("Tutorial_L_2_4_MarketHint_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				tutorial:variables():setBool("Clickable", true)
				gameInfo:getActiveBetaStat():setBool("Level7MarketHint", true)
			elseif (message:is("Market", "press")) then
				tutorial:variables():setBool("Tutorial_L_2_4_MarketHint", true)
				tutorial:variables():setInt("Tutorial_L_2_4_MarketHint_State", 2)
			end
		elseif (tutorial:variables():getInt("Tutorial_L_2_4_MarketHint_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
				tutorial:variables():eraseName("Tutorial_L_2_4_MarketHint_Time")
				tutorial:variables():eraseName("Tutorial_L_2_4_MarketHint")
				tutorial:variables():setInt("Tutorial_L_2_4_MarketHint_State", 0)
			elseif (message:is("Market", "press")) then
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
				tutorial:variables():setBool("Tutorial_L_2_4_MarketHint", true)
				tutorial:variables():setInt("Tutorial_L_2_4_MarketHint_State", 2)
			end
		end
	end
end

function L_2_4(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("L_2_4_Market")
		tutorial:queueAddMessage("L_2_4_MarketOrder")
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		if (not gameInfo:isDataSet("MoneyLostHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoneyLost")
		end
		tutorial:queueAddMessage("Tutorial_L_2_4_MarketHint")
		
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_2_4_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:variables():setFloat("MarketMarker", 3.5)
		
		tutorial:variables():setBool("TutorialLock", true)
	end	
	if (message:is("LoadLevelFunctionTable") or message:is("LoadLevel")) then	
		tutorialFunctionTable[1] = function(message)
			
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 2)
				tutorial:variables():setBool("TutorialMarketPodstava", true)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialToSelect", true)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
		
	if (tutorialFunctionTable[tutorial:variables():getInt("TutorialState")] ~= nil) then
		tutorialFunctionTable[tutorial:variables():getInt("TutorialState")](message)
	end
end

function Tutorial_L_3_1_RobberHint(message)
	if (not gameInfo:getActiveBetaStat():findName("Level8RobberHint")) then
		gameInfo:getActiveBetaStat():setBool("Level8RobberHint", false)
	end
	if (not tutorial:variables():findName("Tutorial_L_3_1_RobberHint")) then
		if (message:is("Update") and not tutorial:variables():findName("L_3_1_Robber")
			and not tutorial:variables():getBool("TutorialLock") and tutorial:game():isFirstCommandWasGiven()) then
			if (not tutorial:variables():findName("Tutorial_L_3_1_RobberHint_Time")) then
				tutorial:variables():setFloat("Tutorial_L_3_1_RobberHint_Time", 60.0)
			end
			t = tutorial:variables():getFloat("Tutorial_L_3_1_RobberHint_Time")
			t = t - message:getVariables():getFloat("TimeDelta")
			if (t <= 0.0 and not tutorial:game():isEnded()) then
				tutorial:variables():setBool("Tutorial_L_3_1_RobberHint", true)
				tutorial:variables():setInt("Tutorial_L_3_1_RobberHint_State", 0)
				tutorial:variables():eraseName("Tutorial_L_3_1_RobberHint_Time")
			else
				tutorial:variables():setFloat("Tutorial_L_3_1_RobberHint_Time", t)
			end
		end
	end
	if (tutorial:variables():findName("Tutorial_L_3_1_RobberHint")) then
		if (tutorial:variables():getInt("Tutorial_L_3_1_RobberHint_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_3_1_8", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_3_1_8")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				
				fieldPos = tutorial:game():getObject(442798):getScreenPosition()
				arrow = tutorial:addArrow()
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setScale(1.0)
				tutorial:getArrow(arrow):setShowTimer(2.5)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 40)
				tutorial:variables():setFloat("TutorialTextDelayTime", 0.0)
				tutorial:variables():setInt("Tutorial_L_3_1_RobberHint_State", 1)
				tutorial:variables():setInt("L_3_1_Robber_State", 2)
				tutorial:variables():setBool("L_3_1_Robber", true)
				tutorial:variables():setBool("TutorialLock", true)
				gameInfo:getActiveBetaStat():setBool("Level8RobberHint", true)
			elseif (message:is("Update") and tutorial:variables():findName("L_3_1_Robber")) then
				tutorial:variables():setInt("Tutorial_L_3_1_RobberHint_State", 3)
			end
		elseif (tutorial:variables():getInt("Tutorial_L_3_1_RobberHint_State") == 1) then
			if (message:is("TutorialOk")) then
				tutorial:switchCharacter("Tippy")
				tutorial:switchText("L_3_1_4", 0.5)
				tutorial:variables():setInt("Tutorial_L_3_1_RobberHint_State", 2)
			end
		elseif (tutorial:variables():getInt("Tutorial_L_3_1_RobberHint_State") == 2) then
			if (message:is("TutorialOk")) then
				tutorial:hideArrows(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
				tutorial:variables():eraseName("Tutorial_L_3_1_RobberHint_Time")
				tutorial:variables():setInt("Tutorial_L_3_1_RobberHint_State", 3)
			end
		end
	end
end

function L_3_1_Robber(message)
	if (not tutorial:variables():findName("L_3_1_Robber") and tutorial:game():getSelected() and tutorial:game():getSelected():id() == 442798) then
		tutorial:variables():setBool("L_3_1_Robber", true)
		tutorial:variables():setInt("L_3_1_Robber_State", 0)
	end
	if (tutorial:variables():findName("L_3_1_Robber")) then
		if (tutorial:variables():getInt("L_3_1_Robber_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_3_1_4", 0.5)
					tutorial:switchCharacter("Tippy")
				else
					tutorial:setText("L_3_1_4")
					tutorial:setCharacter("Tippy")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_3_1_Robber_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				tutorial:variables():setBool("TutorialKeepSelection", true)
				tutorial:setSelected()
			end
		elseif (tutorial:variables():getInt("L_3_1_Robber_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_3_1_Robber_State", 2)
				tutorial:hide(0.25)
				tutorial:unsetSelected()
				tutorial:variables():setBool("TutorialKeepSelection", false)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_3_1_Garden(message)
	if (not tutorial:variables():findName("L_3_1_Garden") and message:is("GardenBuilt")) then
		tutorial:variables():setBool("L_3_1_Garden", true)
		tutorial:variables():setInt("L_3_1_Garden_State", 0)
		arrow = tutorial:addArrow()
		tutorial:variables():setInt("L_3_1_GardenArrow", arrow)
		tutorial:getArrow(arrow):setAngle(270)
		tutorial:getArrow(arrow):setScale(1.0)
		tutorial:getArrow(arrow):setPosition(message:getVariables():getPoint("Position").x + 35, message:getVariables():getPoint("Position").y + 20)
	end
	if (tutorial:variables():findName("L_3_1_Garden")) then
		if (tutorial:variables():getInt("L_3_1_Garden_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_3_1_7", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_3_1_7")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:getArrow(tutorial:variables():getInt("L_3_1_GardenArrow")):setShowTimer(1.5)
				tutorial:getArrow(tutorial:variables():getInt("L_3_1_GardenArrow")):show(0.5)
				tutorial:getArrow(tutorial:variables():getInt("L_3_1_GardenArrow")):moveTo(
					tutorial:getArrow(tutorial:variables():getInt("L_3_1_GardenArrow")):getPosition().x,
					tutorial:getArrow(tutorial:variables():getInt("L_3_1_GardenArrow")):getPosition().y,
					tutorial:getArrow(tutorial:variables():getInt("L_3_1_GardenArrow")):getAngle(),
					0.7, 0.5)
				tutorial:variables():setInt("L_3_1_Garden_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
			end
		elseif (tutorial:variables():getInt("L_3_1_Garden_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_3_1_Garden_State", 2)
				tutorial:getArrow(tutorial:variables():getInt("L_3_1_GardenArrow")):hide(0.5)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function Tutorial_Smart_Happy(message)
	if (not gameInfo:getActiveBetaStat():findName("HappyHint")) then
		gameInfo:getActiveBetaStat():setInt("HappyHint", 0)
	end
	if (not tutorial:variables():findName("Tutorial_Smart_Happy")) then
		if (message:is("BuildingBuilt") and not gameInfo:isDataSet("HappyHint") and
			message:getVariables():findName("House1")) then
			tutorial:variables():setBool("Tutorial_Smart_Happy", true)
			tutorial:variables():setInt("Tutorial_Smart_Happy_State", 0)
			if (message:getVariables():findName("House1")) then
				arrow = tutorial:addArrow()
				tutorial:variables():setInt("TutorialSmartHappyArrow1", arrow)
				tutorial:getArrow(arrow):setPosition(message:getVariables():getPoint("House1").x + 35, message:getVariables():getPoint("House1").y + 20)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setScale(0.7)
				if (message:getVariables():findName("HouseType")) then
					tutorial:variables():setString("TutorialSmartHappyMessage", "Tutorial_Smart_Happy3")
				else
					tutorial:variables():setString("TutorialSmartHappyMessage", "Tutorial_Smart_Happy1")
				end
			end
			if (message:getVariables():findName("House2")) then
				arrow = tutorial:addArrow()
				tutorial:variables():setInt("TutorialSmartHappyArrow2", arrow)
				tutorial:getArrow(arrow):setPosition(message:getVariables():getPoint("House2").x + 35, message:getVariables():getPoint("House2").y + 20)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setScale(0.7)
				tutorial:variables():setString("TutorialSmartHappyMessage", "Tutorial_Smart_Happy2")
			end
		end
	end
	if (tutorial:variables():findName("Tutorial_Smart_Happy")) then
		if (tutorial:variables():getInt("Tutorial_Smart_Happy_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText(tutorial:variables():getString("TutorialSmartHappyMessage"), 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText(tutorial:variables():getString("TutorialSmartHappyMessage"))
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				if (tutorial:variables():findName("TutorialSmartHappyArrow1")) then
					tutorial:getArrow(tutorial:variables():getInt("TutorialSmartHappyArrow1")):setShowTimer(1.5)
					tutorial:getArrow(tutorial:variables():getInt("TutorialSmartHappyArrow1")):show(0.5)
				end
				if (tutorial:variables():findName("TutorialSmartHappyArrow2")) then
					tutorial:getArrow(tutorial:variables():getInt("TutorialSmartHappyArrow2")):setShowTimer(1.5)
					tutorial:getArrow(tutorial:variables():getInt("TutorialSmartHappyArrow2")):show(0.5)
				end
				tutorial:variables():setInt("Tutorial_Smart_Happy_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				gameInfo:setBoolData("HappyHint", true)
				gameInfo:getActiveBetaStat():setInt("HappyHint", gameInfo:getLevel() + 1)
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_Happy_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("Tutorial_Smart_Happy_State", 2)
				if (tutorial:variables():findName("TutorialSmartHappyArrow1")) then
					tutorial:getArrow(tutorial:variables():getInt("TutorialSmartHappyArrow1")):hide(0.25)
				end
				if (tutorial:variables():findName("TutorialSmartHappyArrow2")) then
					tutorial:getArrow(tutorial:variables():getInt("TutorialSmartHappyArrow2")):hide(0.25)
				end
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_3_1(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("L_3_1_Robber")
		tutorial:queueAddMessage("L_3_1_Garden")
		tutorial:queueAddMessage("Tutorial_Smart_Happy")
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		if (not gameInfo:isDataSet("MoneyLostHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoneyLost")
		end
		tutorial:queueAddMessage("Tutorial_L_3_1_RobberHint")
			
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_3_1_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		
		tutorial:addArrow()
		
		tutorial:variables():setBool("TutorialLock", true)
	end	
	if (message:is("LoadLevelFunctionTable") or message:is("LoadLevel")) then	
		tutorialFunctionTable[1] = function(message)
			
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 2)
				tutorial:switchText("L_3_1_2", 0.5)
			end
		end
		tutorialFunctionTable[2] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 3)
				tutorial:switchText("L_3_1_3", 0.5)
				tutorial:switchCharacter("Sedrik")
			end
		end
		tutorialFunctionTable[3] = function(message)
			if (message:is("TutorialContextHided")) then
				tutorial:getArrow(0):setPosition(622, 725)
				tutorial:getArrow(0):setAngle(90)
				tutorial:getArrow(0):setShowTimer(1.5)
				tutorial:getArrow(0):setScale(1.25)
				tutorial:getArrow(0):show(0.5)
			elseif (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 6)
				tutorial:getArrow(0):hide(0.25)
				tutorial:syncJumpWidget("HappinessCount", -1)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialToSelect", true)
				tutorial:variables():setBool("TutorialLock", false)
			elseif (message:is("ArrowShow")) then
				tutorial:syncJumpWidget("HappinessCount", 0)
			end
		end
		tutorialFunctionTable[6] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 8)
				tutorial:switchText("L_3_1_6", 0.5)
			end
		end
		tutorialFunctionTable[7] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 9)
				tutorial:hide(0.25)
			end
		end
	end
	
	if (tutorialFunctionTable[tutorial:variables():getInt("TutorialState")] ~= nil) then
		tutorialFunctionTable[tutorial:variables():getInt("TutorialState")](message)
	end
end

function L_3_2(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("Tutorial_Smart_Happy")
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		if (not gameInfo:isDataSet("MoneyLostHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoneyLost")
		end
		
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_3_2_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		
		tutorial:variables():setBool("TutorialLock", true)
	end	
	if (message:is("LoadLevelFunctionTable") or message:is("LoadLevel")) then	
		tutorialFunctionTable[1] = function(message)
			
			if (message:is("TutorialOk", "press")) then
				tutorial:switchText("L_3_2_2", 0.5)
				tutorial:variables():setInt("TutorialState", 2)
			end
		end
		tutorialFunctionTable[2] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:switchCharacter("Sedrik")
				tutorial:switchText("L_3_2_3", 0.5)
				tutorial:variables():setInt("TutorialState", 3)
			end
		end
		tutorialFunctionTable[3] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 3)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialToSelect", true)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
	
	if (tutorialFunctionTable[tutorial:variables():getInt("TutorialState")] ~= nil) then
		tutorialFunctionTable[tutorial:variables():getInt("TutorialState")](message)
	end
end

function L_3_3_BankComplete(message)
	if (not tutorial:variables():findName("L_3_3_BankComplete_BankReady") and message:is("BuildingBuilt") and message:getVariables():getInt("Type") == BankType) then
		tutorial:variables():setBool("L_3_3_BankComplete_BankReady", true)
		tutorial:variables():setInt("L_3_3_BankComplete_State", 0)
	end
	if (tutorial:variables():findName("L_3_3_BankComplete_BankReady")) then
		if (tutorial:variables():getInt("L_3_3_BankComplete_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_3_3_3", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_3_3_3")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_3_3_BankComplete_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
			end
		elseif (tutorial:variables():getInt("L_3_3_BankComplete_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_3_3_BankComplete_State", 2)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_3_3_Robber(message)
	if (not tutorial:variables():findName("L_3_3_Robber") and tutorial:game():getSelected() and tutorial:game():getSelected():id() == 1926654) then
		tutorial:variables():setBool("L_3_3_Robber", true)
		tutorial:variables():setInt("L_3_3_Robber_State", 0)
	end
	if (tutorial:variables():findName("L_3_3_Robber")) then
		if (tutorial:variables():getInt("L_3_3_Robber_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_3_3_1", 0.5)
					tutorial:switchCharacter("Tippy")
				else
					tutorial:setText("L_3_3_1")
					tutorial:setCharacter("Tippy")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_3_3_Robber_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				tutorial:variables():setBool("TutorialKeepSelection", true)
				tutorial:setSelected()
			end
		elseif (tutorial:variables():getInt("L_3_3_Robber_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_3_3_Robber_State", 2)
				tutorial:hide(0.25)
				tutorial:unsetSelected()
				tutorial:variables():setBool("TutorialKeepSelection", false)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_3_3_Bank(message)
	if (not gameInfo:getActiveBetaStat():findName("BankAlmostFull")) then
		gameInfo:getActiveBetaStat():setBool("BankAlmostFull", false)
	end
	if (not tutorial:variables():findName("L_3_3_Bank_BankReady") and message:is("BankAlmostFull") and
		not tutorial:variables():findName("L_3_3_TutorialBankGet")) then
		tutorial:variables():setBool("L_3_3_Bank_BankReady", true)
		tutorial:variables():setInt("L_3_3_Bank_State", 0)
		tutorial:variables():setInt("L_3_3_Tutorial_Bank_x", message:getVariables():getPoint("Position").x)
		tutorial:variables():setInt("L_3_3_Tutorial_Bank_y", message:getVariables():getPoint("Position").y + 40)
	end
	if (tutorial:variables():findName("L_3_3_Bank_BankReady")) then
		if (tutorial:variables():getInt("L_3_3_Bank_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_3_3_Bank", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_3_3_Bank")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				arrow = tutorial:addArrow()
				tutorial:variables():setInt("L_3_3_TutorialBankArrow", arrow)
				tutorial:getArrow(arrow):setPosition(tutorial:variables():getInt("L_3_3_Tutorial_Bank_x"), tutorial:variables():getInt("L_3_3_Tutorial_Bank_y"))
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(1.5)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:variables():setInt("L_3_3_Bank_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				gameInfo:getActiveBetaStat():setBool("BankAlmostFull", true)
			end
		elseif (tutorial:variables():getInt("L_3_3_Bank_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:getArrow(tutorial:variables():getInt("L_3_3_TutorialBankArrow")):hide(0.25)
				tutorial:variables():setInt("L_3_3_Bank_State", 2)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
	if (message:is("BankGetMoney", "press")) then
		tutorial:variables():setBool("L_3_3_TutorialBankGet", true)
	end
end

function L_3_3(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("L_3_3_BankComplete")
		tutorial:queueAddMessage("L_3_3_Bank")
		tutorial:queueAddMessage("L_3_3_Robber")
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		if (not gameInfo:isDataSet("MoneyLostHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoneyLost")
		end
					
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_3_3_2")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		
		tutorial:variables():setBool("TutorialLock", true)
	end	
	if (message:is("LoadLevelFunctionTable") or message:is("LoadLevel")) then			
		tutorialFunctionTable[1] = function(message)
			
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 2)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialToSelect", true)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
		
		tutorial:variables():setInt("TutorialRobberState", 0)
	end
	
	if (tutorialFunctionTable[tutorial:variables():getInt("TutorialState")] ~= nil) then
		tutorialFunctionTable[tutorial:variables():getInt("TutorialState")](message)
	end
	
	if (tutorial:variables():getInt("TutorialRobberState") == 1) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialRobberState", 2)
			tutorial:hide(0.25)
		end
	end
end

function L_3_4_Chest(message)
	if (not tutorial:variables():findName("L_3_4_Chest") and message:is("ChestFinished")) then
		tutorial:variables():setBool("L_3_4_Chest", true)
		tutorial:variables():setInt("L_3_4_Chest_State", 0)
	end
	if (tutorial:variables():findName("L_3_4_Chest")) then
		if (tutorial:variables():getInt("L_3_4_Chest_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_3_4_4", 0.5)
					tutorial:switchCharacter("Tippy")
				else
					tutorial:setText("L_3_4_4")
					tutorial:setCharacter("Tippy")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_3_4_Chest_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
			end
		elseif (tutorial:variables():getInt("L_3_4_Chest_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_3_4_Chest_State", 2)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_3_4_ChestHint(message)
	if (not gameInfo:getActiveBetaStat():findName("ChestHint")) then
		gameInfo:getActiveBetaStat():setBool("ChestHint", false)
	end
	if (not tutorial:variables():findName("L_3_4_ChestHint")) then
		if (message:is("Update")) then
			if (not tutorial:variables():findName("TutorialChestHintTime")) then
				tutorial:variables():setFloat("TutorialChestHintTime", 90.0)
			end
			t = tutorial:variables():getFloat("TutorialChestHintTime")
			t = t - message:getVariables():getFloat("TimeDelta")
			if (t <= 0.0 and not tutorial:game():isEnded()) then
				tutorial:variables():setBool("L_3_4_ChestHint", true)
				tutorial:variables():setInt("L_3_4_ChestHint_State", 0)
				tutorial:variables():eraseName("TutorialChestHintTime")
			else
				tutorial:variables():setFloat("TutorialChestHintTime", t)
			end
		elseif (message:is("ChestWorkers")) then
			if (message:getIntegerParam() < 1 or message:getIntegerParam() > 4) then
				tutorial:variables():eraseName("TutorialChestHintTime")
			end
		end
	end
	if (tutorial:variables():findName("L_3_4_ChestHint")) then
		if (tutorial:variables():getInt("L_3_4_ChestHint_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_3_4_ChestHint", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_3_4_ChestHint")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:getArrow(1):setHided()
				tutorial:getArrow(1):setPosition(700, 600)
				tutorial:getArrow(1):setAngle(270)
				tutorial:getArrow(1):setShowTimer(1.5)
				tutorial:getArrow(1):show(0.5)
				tutorial:variables():setInt("L_3_4_ChestHint_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				gameInfo:getActiveBetaStat():setBool("ChestHint", true)
			end
		elseif (tutorial:variables():getInt("L_3_4_ChestHint_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_3_4_ChestHint_State", 0)
				tutorial:variables():eraseName("L_3_4_ChestHint")
				tutorial:getArrow(1):hide(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_3_4(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("L_3_4_Chest")
		tutorial:queueAddMessage("L_3_4_ChestHint")
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		if (not gameInfo:isDataSet("MoneyLostHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoneyLost")
		end
					
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_3_4_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:addArrow()
		tutorial:getArrow(0):setPosition(700, 555)
		tutorial:getArrow(0):setAngle(90)
		tutorial:getArrow(0):setShowTimer(2.5)
		tutorial:getArrow(0):show(0.5)
		tutorial:setCharacter("Tippy")
		
		tutorial:addArrow()
		
		tutorial:variables():setBool("TutorialLock", true)
	end	
	if (message:is("LoadLevelFunctionTable") or message:is("LoadLevel")) then	
		tutorialFunctionTable[1] = function(message)
			
			if (message:is("TutorialOk", "press")) then
				tutorial:switchCharacter("Sedrik")
				tutorial:switchText("L_3_4_2", 0.5)
				tutorial:variables():setInt("TutorialState", 2)
			end
		end
		tutorialFunctionTable[2] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:switchCharacter("Tippy")
				tutorial:switchText("L_3_4_3", 0.5)
				tutorial:variables():setInt("TutorialState", 3)
			end
		end
		tutorialFunctionTable[3] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 4)
				tutorial:getArrow(0):hide(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialToSelect", true)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
	
	if (tutorialFunctionTable[tutorial:variables():getInt("TutorialState")] ~= nil) then
		tutorialFunctionTable[tutorial:variables():getInt("TutorialState")](message)
	end
end

function L_3_5(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		if (not gameInfo:isDataSet("MoneyLostHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoneyLost")
		end
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_3_5_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Sedrik")
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:addArrow()
		
		tutorial:variables():setBool("TutorialLock", true)
	end	
	if (message:is("LoadLevelFunctionTable") or message:is("LoadLevel")) then	
		tutorialFunctionTable[1] = function(message)
			
			if (message:is("TutorialOk", "press")) then
				tutorial:switchText("L_3_5_2", 0.5)
				tutorial:switchCharacter("Tippy")
				tutorial:variables():setInt("TutorialState", 2)
				
				fieldPos = tutorial:game():getObject(4937060):getScreenPosition()
				arrow = 0
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(1.5)
				tutorial:getArrow(arrow):show(0.5)
				fieldPos = tutorial:game():getObject(4937062):getScreenPosition()
				arrow = 1
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(1.5)
				tutorial:getArrow(arrow):show(0.5)
				fieldPos = tutorial:game():getObject(4937064):getScreenPosition()
				arrow = 2
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(1.5)
				--tutorial:getArrow(arrow):show(0.5)
				fieldPos = tutorial:game():getObject(4937066):getScreenPosition()
				arrow = 3
				tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(1.5)
				tutorial:getArrow(arrow):show(0.5)
			end
		end
		tutorialFunctionTable[2] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 3)
				tutorial:getArrow(0):hide(0.5)
				tutorial:getArrow(1):hide(0.5)
				tutorial:getArrow(2):hide(0.5)
				tutorial:getArrow(3):hide(0.5)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialToSelect", true)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
	
	if (tutorialFunctionTable[tutorial:variables():getInt("TutorialState")] ~= nil) then
		tutorialFunctionTable[tutorial:variables():getInt("TutorialState")](message)
	end
end

-- 13 уровень

function L_4_1_Repair(message)
	if (not tutorial:variables():findName("L_4_1_Repair") and message:is("HouseBreak")) then
		tutorial:variables():setBool("L_4_1_Repair", true)
		tutorial:variables():setInt("L_4_1_Repair_State", 0)
		arrow = tutorial:addArrow()
		tutorial:variables():setInt("L_4_1_RepairArrow", arrow)
		tutorial:getArrow(arrow):setAngle(270)
		tutorial:getArrow(arrow):setScale(1.0)
		tutorial:getArrow(arrow):setPosition(message:getVariables():getPoint("Position").x, message:getVariables():getPoint("Position").y + 60)
	end
	if (tutorial:variables():findName("L_4_1_Repair")) then
		if (tutorial:variables():getInt("L_4_1_Repair_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_4_1_3", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_4_1_3")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:getArrow(tutorial:variables():getInt("L_4_1_RepairArrow")):setShowTimer(1.5)
				tutorial:getArrow(tutorial:variables():getInt("L_4_1_RepairArrow")):show(0.5)
				tutorial:variables():setInt("L_4_1_Repair_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
			end
		elseif (tutorial:variables():getInt("L_4_1_Repair_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_4_1_Repair_State", 2)
				tutorial:getArrow(tutorial:variables():getInt("L_4_1_RepairArrow")):hide(0.5)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_4_1(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("L_4_1_Repair")
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_4_1_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_4_1_2", 0.5)
			tutorial:switchCharacter("Sedrik")
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

-- 14 уровень
function L_4_2(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_4_2_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		
		
		tutorial:addArrow()
		tutorial:getArrow(0):setPosition(560, 630)
		tutorial:getArrow(0):setAngle(270)
		tutorial:getArrow(0):setShowTimer(2.5)
		tutorial:getArrow(0):show(0.5)
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_4_2_2", 0.5)
			tutorial:switchCharacter("Sedrik")
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:getArrow(0):hide(0.5)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

-- 15 уровень
function L_4_3(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_4_3_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Sedrik")
		
		fieldPos = tutorial:game():getObject(1318266):getScreenPosition()
		arrow = tutorial:addArrow()
		tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 15)
		tutorial:getArrow(arrow):setAngle(270)
		tutorial:getArrow(arrow):setShowTimer(2.5)
		tutorial:getArrow(arrow):show(0.5)
		fieldPos = tutorial:game():getObject(1318267):getScreenPosition()
		arrow = tutorial:addArrow()
		tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 15)
		tutorial:getArrow(arrow):setAngle(270)
		tutorial:getArrow(arrow):setShowTimer(2.5)
		tutorial:getArrow(arrow):show(0.5)
		fieldPos = tutorial:game():getObject(1318268):getScreenPosition()
		arrow = tutorial:addArrow()
		tutorial:getArrow(arrow):setPosition(fieldPos.x, fieldPos.y + 15)
		tutorial:getArrow(arrow):setAngle(270)
		tutorial:getArrow(arrow):setShowTimer(2.5)
		tutorial:getArrow(arrow):show(0.5)
					
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_4_3_2", 0.5)
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:getArrow(0):hide(0.25)
			tutorial:getArrow(1):hide(0.25)
			tutorial:getArrow(2):hide(0.25)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

-- 16 уровень
function L_4_4(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_4_4_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 2)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

-- 16 уровень
function L_4_5(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_4_5_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Sedrik")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_4_5_2", 0.5)
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_4_6_BalloonHint(message)
	if (not gameInfo:getActiveBetaStat():findName("BalloonHint")) then
		gameInfo:getActiveBetaStat():setBool("BalloonHint", false)
	end
	if (not tutorial:variables():findName("L_4_6_BalloonHint") and message:is("BalloonOverflow")) then
		tutorial:variables():setBool("L_4_6_BalloonHint", true)
		tutorial:variables():setInt("L_4_6_BalloonHint_State", 0)
	end
	if (tutorial:variables():findName("L_4_6_BalloonHint")) then
		if (tutorial:variables():getInt("L_4_6_BalloonHint_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_4_6_BalloonHint", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_4_6_BalloonHint")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_4_6_BalloonHint_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				gameInfo:getActiveBetaStat():setBool("BalloonHint", true)
			end
		elseif (tutorial:variables():getInt("L_4_6_BalloonHint_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_4_6_BalloonHint_State", 0)
				tutorial:variables():eraseName("L_4_6_BalloonHint")
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

-- 17 уровень
function L_4_6(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("L_4_6_BalloonHint")
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_4_6_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_4_6_2", 0.5)
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

-- 18 уровень
function L_5_1(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_5_1_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Sedrik")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_5_1_2", 0.5)
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_5_2(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
				
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_5_2_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		
		arrow = tutorial:addArrow()
		tutorial:getArrow(arrow):setPosition(306, 625)
		tutorial:getArrow(arrow):setAngle(90)
		tutorial:getArrow(arrow):setShowTimer(2.5)
		tutorial:getArrow(arrow):show(0.5)
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	
	if (tutorial:variables():getInt("TutorialState") == 1) then
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_5_2_2", 0.5)
			tutorial:switchCharacter("Sedrik")
			tutorial:getArrow(0):moveTo(375, 555, 90, 1.0, 0.5)
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:getArrow(0):hide(0.25)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_5_3_Bank(message)
	if (not tutorial:variables():findName("L_5_3_Bank") and message:is("BuildingBuilt") and message:getVariables():getInt("Type") == BankType) then
		tutorial:variables():setBool("L_5_3_Bank", true)
		tutorial:variables():setInt("L_5_3_Bank_State", 0)
	end
	if (tutorial:variables():findName("L_5_3_Bank")) then
		if (tutorial:variables():getInt("L_5_3_Bank_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_5_3_3", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_5_3_3")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_5_3_Bank_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
			end
		elseif (tutorial:variables():getInt("L_5_3_Bank_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_5_3_Bank_State", 2)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialToSelect", true)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

-- 20 уровень
function L_5_3(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("L_5_3_Bank")
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_5_3_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:switchCharacter("Sedrik")
			tutorial:switchText("L_5_3_2", 0.5)
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

-- 21 уровень
function L_5_4(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_5_4_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Sedrik")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:switchCharacter("Tippy")
			tutorial:switchText("L_5_4_2", 0.5)
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_5_5(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_5_5_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Sedrik")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_5_5_2", 0.5)
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_5_6(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_5_7_ShipHint(message)
	if (not gameInfo:getActiveBetaStat():findName("ShipHint")) then
		gameInfo:getActiveBetaStat():setBool("ShipHint", false)
	end
	if (not tutorial:variables():findName("L_5_7_ShipHint")) then
		if (message:is("Update")) then
			if (not tutorial:variables():findName("TutorialShipHintTime")) then
				tutorial:variables():setFloat("TutorialShipHintTime", 90.0)
			end
			if (tutorial:variables():findName("L_5_7_ShipHint_Pause")) then
				tutorial:variables():eraseName("L_5_7_ShipHint_Pause")
			else
				t = tutorial:variables():getFloat("TutorialShipHintTime")
				t = t - message:getVariables():getFloat("TimeDelta")
				if (t <= 0.0 and not tutorial:game():isEnded()) then
					tutorial:variables():setBool("L_5_7_ShipHint", true)
					tutorial:variables():setInt("L_5_7_ShipHint_State", 0)
					tutorial:variables():eraseName("TutorialShipHintTime")
				else
					tutorial:variables():setFloat("TutorialShipHintTime", t)
				end
			end
		elseif (message:is("ShipEndMaterials")) then
			tutorial:variables():setBool("L_5_7_ShipHint_Pause", true)
		elseif (message:is("ShipWorkers")) then
			if (message:getIntegerParam() < 1 or message:getIntegerParam() > 4) then
				tutorial:variables():eraseName("TutorialShipHintTime")
			end
		end
	end
	if (tutorial:variables():findName("L_5_7_ShipHint")) then
		if (tutorial:variables():getInt("L_5_7_ShipHint_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_5_7_ShipHint", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_5_7_ShipHint")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				fieldPos = tutorial:game():getObject(2317354):getScreenPosition()
				tutorial:getArrow(1):setHided()
				tutorial:getArrow(1):setPosition(fieldPos.x, fieldPos.y + 40)
				tutorial:getArrow(1):setAngle(270)
				tutorial:getArrow(1):setShowTimer(1.5)
				tutorial:getArrow(1):show(0.5)
				tutorial:variables():setInt("L_5_7_ShipHint_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				gameInfo:getActiveBetaStat():setBool("ShipHint", true)
			end
		elseif (tutorial:variables():getInt("L_5_7_ShipHint_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_5_7_ShipHint_State", 0)
				tutorial:variables():eraseName("L_5_7_ShipHint")
				tutorial:getArrow(1):hide(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_5_7_ShipEndMaterials(message)
	if (not gameInfo:getActiveBetaStat():findName("ShipMaterialsHint")) then
		gameInfo:getActiveBetaStat():setBool("ShipMaterialsHint", false)
	end
	if (not tutorial:variables():findName("L_5_7_ShipEndMaterials")) then
		if (message:is("ShipEndMaterials")) then
			tutorial:variables():setBool("L_5_7_ShipEndMaterials", true)
			tutorial:variables():setInt("L_5_7_ShipEndMaterials_State", 0)
		end
	end
	if (tutorial:variables():findName("L_5_7_ShipEndMaterials")) then
		if (tutorial:variables():getInt("L_5_7_ShipEndMaterials_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_5_7_4", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_5_7_4")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				fieldPos = tutorial:game():getObject(2317354):getScreenPosition()
				tutorial:getArrow(1):setPosition(fieldPos.x, fieldPos.y + 40)
				tutorial:getArrow(1):setAngle(270)
				tutorial:getArrow(1):setShowTimer(1.5)
				tutorial:getArrow(1):show(0.5)
				tutorial:variables():setInt("L_5_7_ShipEndMaterials_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				gameInfo:getActiveBetaStat():setBool("ShipMaterialsHint", true)
			end
		elseif (tutorial:variables():getInt("L_5_7_ShipEndMaterials_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_5_7_ShipEndMaterials_State", 2)
				-- tutorial:variables():eraseName("L_5_7_ShipEndMaterials")
				tutorial:getArrow(1):hide(0.5)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_5_7(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("L_5_7_ShipHint")
		tutorial:queueAddMessage("L_5_7_ShipEndMaterials")
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_5_7_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:setCharacter("Tippy")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			fieldPos = tutorial:game():getObject(2317354):getScreenPosition()
			tutorial:getArrow(0):setPosition(fieldPos.x, fieldPos.y + 40)
			tutorial:getArrow(0):setAngle(270)
			tutorial:getArrow(0):setShowTimer(1.5)
			tutorial:getArrow(0):show(0.5)
			tutorial:switchText("L_5_7_2", 0.5)
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:getArrow(0):hide(0.25)
			tutorial:switchText("L_5_7_3", 0.5)
			tutorial:switchCharacter("Sedrik")
		end
	elseif (tutorial:variables():getInt("TutorialState") == 3) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 4)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_5_8(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_5_8_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		
		tutorial:variables():setBool("TutorialLock", true)
	end	
	if (message:is("LoadLevelFunctionTable") or message:is("LoadLevel")) then	
		tutorialFunctionTable[1] = function(message)
			
			if (message:is("TutorialOk", "press")) then
				tutorial:switchText("L_5_8_2", 0.5)
				tutorial:switchCharacter("Sedrik")
				tutorial:variables():setInt("TutorialState", 2)
			end
		end
		tutorialFunctionTable[2] = function(message)
			
			if (message:is("TutorialOk", "press")) then
				tutorial:switchText("L_5_8_3", 0.5)
				tutorial:switchCharacter("Tippy")
				tutorial:variables():setInt("TutorialState", 3)
			end
		end
		tutorialFunctionTable[3] = function(message)
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("TutorialState", 4)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialToSelect", true)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
	if (tutorialFunctionTable[tutorial:variables():getInt("TutorialState")] ~= nil) then
		tutorialFunctionTable[tutorial:variables():getInt("TutorialState")](message)
	end
end

function L_6_1(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_6_1_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Sedrik")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 2)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_6_2_Zaval(message)
	if (not tutorial:variables():findName("L_6_2_Zaval") and tutorial:game():getSelected() and
		(tutorial:game():getSelected():id() == 45778 or tutorial:game():getSelected():id() == 45784 or tutorial:game():getSelected():id() == 45786)) then
		tutorial:variables():setBool("L_6_2_Zaval", true)
		tutorial:variables():setInt("L_6_2_Zaval_State", 0)
	end
	if (tutorial:variables():findName("L_6_2_Zaval")) then
		if (tutorial:variables():getInt("L_6_2_Zaval_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_6_2_1", 0.5)
					tutorial:switchCharacter("Tippy")
				else
					tutorial:setText("L_6_2_1")
					tutorial:setCharacter("Tippy")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_6_2_Zaval_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				tutorial:variables():setBool("TutorialKeepSelection", true)
				tutorial:setSelected()
			end
		elseif (tutorial:variables():getInt("L_6_2_Zaval_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:switchText("L_6_2_2", 0.5)
				tutorial:switchCharacter("Sedrik")
				tutorial:variables():setInt("L_6_2_Zaval_State", 2)
			end
		elseif (tutorial:variables():getInt("L_6_2_Zaval_State") == 2) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_6_2_Zaval_State", 3)
				tutorial:hide(0.25)
				tutorial:unsetSelected()
				tutorial:variables():setBool("TutorialKeepSelection", false)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_6_2(message)
	if (message:is("LoadLevel")) then
		--tutorial:queueAddMessage("L_6_2_Zaval")
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_6_3(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
				
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_6_3_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Sedrik")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_6_3_2", 0.5)
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_6_4(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
					
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_6_4_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Sedrik")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 2)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_6_5_Zaval(message)
	if (not tutorial:variables():findName("L_6_5_Zaval") and tutorial:game():getSelected() and
		(tutorial:game():getSelected():id() == 45690 or tutorial:game():getSelected():id() == 45688)) then
		tutorial:variables():setBool("L_6_5_Zaval", true)
		tutorial:variables():setInt("L_6_5_Zaval_State", 0)
	end
	if (tutorial:variables():findName("L_6_5_Zaval")) then
		if (tutorial:variables():getInt("L_6_5_Zaval_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_6_5_1", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_6_5_1")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_6_5_Zaval_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				tutorial:variables():setBool("TutorialKeepSelection", true)
				tutorial:setSelected()
			end
		elseif (tutorial:variables():getInt("L_6_5_Zaval_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_6_5_Zaval_State", 2)
				tutorial:hide(0.25)
				tutorial:unsetSelected()
				tutorial:variables():setBool("TutorialKeepSelection", false)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_6_5(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("L_6_5_Zaval")
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_6_6_Circus(message)
	if (not tutorial:variables():findName("L_6_6_Circus") and message:is("CircusReady")) then
		tutorial:variables():setBool("L_6_6_Circus", true)
		tutorial:variables():setInt("L_6_6_Circus_State", 0)
	end
	if (tutorial:variables():findName("L_6_6_Circus")) then
		if (tutorial:variables():getInt("L_6_6_Circus_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_6_6_3", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_6_6_3")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_6_6_Circus_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
			end
		elseif (tutorial:variables():getInt("L_6_6_Circus_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:switchText("L_6_6_4", 0.5)
				tutorial:variables():setInt("L_6_6_Circus_State", 2)
			end
		elseif (tutorial:variables():getInt("L_6_6_Circus_State") == 2) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_6_6_Circus_State", 3)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_6_6(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("L_6_6_Circus")
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
			
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_6_6_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Sedrik")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_6_6_2", 0.5)
			tutorial:switchCharacter("Tippy")
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_6_7(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_6_8(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_7_1(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
						
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_7_1_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 2)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_7_2(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
			
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_7_2_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Sedrik")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 2)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_7_3(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_7_4(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
				
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_7_4_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_7_4_2", 0.5)
			tutorial:switchCharacter("Sedrik")
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_7_5(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_7_6(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_7_7(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
			
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_7_7_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		tutorial:addArrow()
		tutorial:getArrow(0):setPosition(170, 430)
		tutorial:getArrow(0):setAngle(270)
		tutorial:getArrow(0):setShowTimer(2.5)
		tutorial:getArrow(0):show(0.5)
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 2)
			tutorial:getArrow(0):hide(0.5)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_7_8(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_7_9(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_8_1(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
			
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_8_1_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Sedrik")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_8_1_2", 0.5)
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_8_2(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_8_3(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_8_4(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_8_5(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
			
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_8_5_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_8_5_2", 0.5)
			tutorial:switchCharacter("Sedrik")
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 3)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_8_6(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_8_7(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_8_8(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_8_9(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_8_10(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
			
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_8_10_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Sedrik")
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:addArrow()
		tutorial:getArrow(0):setPosition(720, 640)
		tutorial:getArrow(0):setAngle(270)
		tutorial:getArrow(0):setShowTimer(2.5)
		tutorial:getArrow(0):show(0.5)
		tutorial:getArrow(1):setPosition(825, 510)
		tutorial:getArrow(1):setAngle(270)
		tutorial:getArrow(1):setShowTimer(2.5)
		tutorial:getArrow(1):show(0.5)
		tutorial:getArrow(2):setPosition(945, 410)
		tutorial:getArrow(2):setAngle(270)
		tutorial:getArrow(2):setShowTimer(2.5)
		tutorial:getArrow(2):show(0.5)
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 2)
			tutorial:getArrow(0):hide(0.5)
			tutorial:getArrow(1):hide(0.5)
			tutorial:getArrow(2):hide(0.5)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_9_1(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_9_2(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_9_2_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_9_2_2", 0.5)
			tutorial:switchCharacter("Sedrik")
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_9_2_3", 0.5)
			tutorial:switchCharacter("Tippy")
			tutorial:variables():setInt("TutorialState", 3)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 3) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 4)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_9_3(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_9_4(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_9_5(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_9_5_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Sedrik")
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_9_5_2", 0.5)
			tutorial:switchCharacter("Tippy")
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_9_5_3", 0.5)
			tutorial:switchCharacter("Sedrik")
			tutorial:variables():setInt("TutorialState", 3)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 3) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 4)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_9_6(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_9_7_Cave(message)
	if (not tutorial:variables():findName("L_9_7_Cave") and message:is("CaveFinished")) then
		tutorial:variables():setBool("L_9_7_Cave", true)
		tutorial:variables():setInt("L_9_7_Cave_State", 0)
	end
	if (tutorial:variables():findName("L_9_7_Cave")) then
		if (tutorial:variables():getInt("L_9_7_Cave_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_9_7_4", 0.5)
					tutorial:switchCharacter("Tippy")
				else
					tutorial:setText("L_9_7_4")
					tutorial:setCharacter("Tippy")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("L_9_7_Cave_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
			end
		elseif (tutorial:variables():getInt("L_9_7_Cave_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("L_9_7_Cave_State", 2)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function L_9_7(message)
	if (message:is("LoadLevel")) then
		tutorial:queueAddMessage("L_9_7_Cave")
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:show(0.25)
		tutorial:variables():setFloat("TutorialShowDelayTime", 1.5)
		tutorial:variables():setInt("TutorialState", 1)
		tutorial:setText("L_9_7_1")
		tutorial:setWidgetVisible("TutorialOk", true)
		tutorial:setCharacter("Tippy")
		tutorial:addArrow()
		tutorial:getArrow(0):setPosition(623, 600)
		tutorial:getArrow(0):setAngle(90)
		tutorial:getArrow(0):setShowTimer(2.5)
		tutorial:getArrow(0):show(0.5)
		
		tutorial:variables():setBool("TutorialLock", true)
	end
	if (tutorial:variables():getInt("TutorialState") == 1) then
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_9_7_2", 0.5)
			tutorial:switchCharacter("Sedrik")
			tutorial:variables():setInt("TutorialState", 2)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 2) then
		if (message:is("TutorialOk", "press")) then
			tutorial:switchText("L_9_7_3", 0.5)
			tutorial:switchCharacter("Tippy")
			tutorial:variables():setInt("TutorialState", 3)
		end
	elseif (tutorial:variables():getInt("TutorialState") == 3) then
		if (message:is("TutorialOk", "press")) then
			tutorial:variables():setInt("TutorialState", 4)
			tutorial:getArrow(0):hide(0.5)
			tutorial:hide(0.25)
			tutorial:variables():setBool("TutorialToSelect", true)
			tutorial:variables():setBool("TutorialLock", false)
		end
	end
end

function L_9_8(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_9_9(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

function L_9_10(message)
	if (message:is("LoadLevel")) then
		if (not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Bank")
		end
		if (not gameInfo:isDataSet("ExpertHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_Expert")
		end
		if (not gameInfo:isDataSet("ZeroTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_ZeroTaxers")
		end
		if (not gameInfo:isDataSet("MoreTaxersHint")) then
			tutorial:queueAddMessage("Tutorial_Smart_MoreTaxers")
		end
		tutorial:variables():setBool("TutorialToSelect", true)
	end
end

-- Умные нах подсказки
function Tutorial_Smart_Gold(message)
	if (not gameInfo:getActiveBetaStat():findName("FirstMoneyBagsHintLevel")) then
		gameInfo:getActiveBetaStat():setInt("FirstMoneyBagsHintLevel", 0)
	end
	if (not tutorial:variables():findName("TutorialSmartGoldFraze")) then
		tutorial:variables():setString("TutorialSmartGoldFraze", "Tutorial_Smart_Gold_1")
	end
	if (not tutorial:variables():findName("Tutorial_Smart_Gold")) then
		if (message:is("Update") and tutorial:variables():findName("SmartMoneyStart")) then
			if (not tutorial:variables():findName("TutorialSmartGoldTime")) then
				if (not tutorial:variables():findName("TutorialSmartGoldTime_First")) then
					tutorial:variables():setFloat("TutorialSmartGoldTime", 20.0)
				else
					tutorial:variables():setFloat("TutorialSmartGoldTime", 25.0)
				end
			end
			if (tutorial:game():getUnorderedMoneyCount() > 0 and not tutorial:isFreeLargeFieldSelected()) then
				t = tutorial:variables():getFloat("TutorialSmartGoldTime")
				t = t - message:getVariables():getFloat("TimeDelta")
				if (t <= 0.0 and not tutorial:game():isEnded()) then
					tutorial:variables():setBool("Tutorial_Smart_Gold", true)
					tutorial:variables():setInt("Tutorial_Smart_Gold_State", 0)
					tutorial:variables():eraseName("TutorialSmartGoldTime")
					tutorial:variables():setBool("TutorialSmartGoldTime_First", true)
				else
					tutorial:variables():setFloat("TutorialSmartGoldTime", t)
				end
			end
		elseif (message:is("RentOrdered")) then
			tutorial:variables():eraseName("TutorialSmartGoldTime")
		end
	end
	if (tutorial:variables():findName("Tutorial_Smart_Gold")) then
		if (tutorial:variables():getInt("Tutorial_Smart_Gold_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText(tutorial:variables():getString("TutorialSmartGoldFraze"), 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText(tutorial:variables():getString("TutorialSmartGoldFraze"))
					tutorial:setCharacter("Sedrik")
				end
				if (tutorial:variables():getString("TutorialSmartGoldFraze") == "Tutorial_Smart_Gold_1") then
					tutorial:variables():setString("TutorialSmartGoldFraze", "Tutorial_Smart_Gold_2")
				else
					tutorial:variables():setString("TutorialSmartGoldFraze", "Tutorial_Smart_Gold_1")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("Tutorial_Smart_Gold_State", 1)
				tutorial:variables():eraseName("TutorialSmartGoldTime")
				tutorial:variables():setBool("TutorialLock", true)
				tutorial:targetAllMoney("SmartGold", 0.5, Point(0, 75), 1.5)
				if (gameInfo:getActiveBetaStat():getInt("FirstMoneyBagsHintLevel") == 0) then
					gameInfo:getActiveBetaStat():setInt("FirstMoneyBagsHintLevel", gameInfo:getLevel() + 1)
				end
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_Gold_State") == 1) then
			if (message:is("TutorialOk", "press") or
				(message:is("Update") and tutorial:game():getUnorderedMoneyCount() == 0)) then
				tutorial:hideArrows(0.25)
				tutorial:variables():setInt("Tutorial_Smart_Gold_State", 0)
				tutorial:variables():eraseName("Tutorial_Smart_Gold")
				tutorial:variables():eraseName("TutorialSmartGoldTime")
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			elseif (message:is("RentGenerated")) then
				arrow = tutorial:addArrow()
				money = tutorial:game():getObject(message:getIntegerParam())
				moneyPos = money:getScreenPosition()
				tutorial:getArrow(arrow):setPosition(moneyPos.x, moneyPos.y + 75)
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:getArrow(arrow):copyTime(tutorial:getArrow(arrow-1))
				tutorial:bindArrowToMoney("SmartGold", arrow, money)
			elseif (message:is("RentOrdered")) then
				tutorial:hideBindedArrow("SmartGold", message:getIntegerParam(), 0.25)
			end
		end
	end
end

function Tutorial_Smart_Money(message)
	if (not gameInfo:getActiveBetaStat():findName("FirstNeedMoreMoneyHintLevel")) then
		gameInfo:getActiveBetaStat():setInt("FirstNeedMoreMoneyHintLevel", 0)
	end
	if (not tutorial:variables():findName("Tutorial_Smart_Money")) then
		if (message:is("MoneyBlock")) then
			if (not tutorial:variables():findName("TutorialSmartMoneyCount")) then
				tutorial:variables():setInt("TutorialSmartMoneyCount", 1) -- изначально 1 попытка
			end
			if (not tutorial:variables():findName("TutorialSmartMoneyCounter")) then
				tutorial:variables():setInt("TutorialSmartMoneyCounter", tutorial:variables():getInt("TutorialSmartMoneyCount"))
			end
			t = tutorial:variables():getInt("TutorialSmartMoneyCounter")
			t = t - 1
			if (t == 0) then
				tutorial:variables():setBool("Tutorial_Smart_Money", true)
				tutorial:variables():setInt("Tutorial_Smart_Money_State", 0)
				tutorial:variables():eraseName("TutorialSmartMoneyCounter")
				if (tutorial:variables():getInt("TutorialSmartMoneyCount") == 1) then
					tutorial:variables():setInt("TutorialSmartMoneyCount", 3)
				elseif (tutorial:variables():getInt("TutorialSmartMoneyCount") == 3) then
					tutorial:variables():setInt("TutorialSmartMoneyCount", 5)
				end
			else
				tutorial:variables():setInt("TutorialSmartMoneyCounter", t)
			end
		end
	end
	if (tutorial:variables():findName("Tutorial_Smart_Money")) then
		if (tutorial:variables():getInt("Tutorial_Smart_Money_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("Tutorial_Smart_Money_1", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("Tutorial_Smart_Money_1")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("Tutorial_Smart_Money_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				if (gameInfo:getActiveBetaStat():getInt("FirstNeedMoreMoneyHintLevel") == 0) then
					gameInfo:getActiveBetaStat():setInt("FirstNeedMoreMoneyHintLevel", gameInfo:getLevel() + 1)
				end
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_Money_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("Tutorial_Smart_Money_State", 0)
				tutorial:variables():eraseName("Tutorial_Smart_Money")
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function Tutorial_Smart_Money_All(message)
	if (not gameInfo:getActiveBetaStat():findName("FirstNeedMoreMoneyHintLevel")) then
		gameInfo:getActiveBetaStat():setInt("FirstNeedMoreMoneyHintLevel", 0)
	end
	if (not tutorial:variables():findName("Tutorial_Smart_Money_All")) then
		if (message:is("MoneyBlock")) then
			if (not tutorial:variables():findName("TutorialSmartMoneyAllCount")) then
				tutorial:variables():setInt("TutorialSmartMoneyAllCount", 3) -- изначально 3 попытки
			end
			if (not tutorial:variables():findName("TutorialSmartMoneyAllCounter")) then
				tutorial:variables():setInt("TutorialSmartMoneyAllCounter", tutorial:variables():getInt("TutorialSmartMoneyAllCount"))
			end
			t = tutorial:variables():getInt("TutorialSmartMoneyAllCounter")
			t = t - 1
			if (t == 0) then
				tutorial:variables():setBool("Tutorial_Smart_Money_All", true)
				tutorial:variables():setInt("Tutorial_Smart_Money_All_State", 0)
				tutorial:variables():eraseName("TutorialSmartMoneyAllCounter")
				if (tutorial:variables():getInt("TutorialSmartMoneyAllCount") == 3) then
					tutorial:variables():setInt("TutorialSmartMoneyAllCount", 5)
				end
			else
				tutorial:variables():setInt("TutorialSmartMoneyAllCounter", t)
			end
		end
	end
	if (tutorial:variables():findName("Tutorial_Smart_Money_All")) then
		if (tutorial:variables():getInt("Tutorial_Smart_Money_All_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("Tutorial_Smart_Money_1", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("Tutorial_Smart_Money_1")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("Tutorial_Smart_Money_All_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				if (gameInfo:getActiveBetaStat():getInt("FirstNeedMoreMoneyHintLevel") == 0) then
					gameInfo:getActiveBetaStat():setInt("FirstNeedMoreMoneyHintLevel", gameInfo:getLevel() + 1)
				end
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_Money_All_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("Tutorial_Smart_Money_All_State", 0)
				tutorial:variables():eraseName("Tutorial_Smart_Money_All")
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function Tutorial_Smart_Materials(message)
	if (not gameInfo:getActiveBetaStat():findName("FirstNeedMoreMaterialsHintLevel")) then
		gameInfo:getActiveBetaStat():setInt("FirstNeedMoreMaterialsHintLevel", 0)
	end
	if (not tutorial:variables():findName("Tutorial_Smart_Materials")) then
		if (message:is("MaterialsBlock")) then
			if (not tutorial:variables():findName("TutorialSmartMaterialsCount")) then
				tutorial:variables():setInt("TutorialSmartMaterialsCount", 1) -- изначально 1 попытка
			end
			if (not tutorial:variables():findName("TutorialSmartMaterialsCounter")) then
				tutorial:variables():setInt("TutorialSmartMaterialsCounter", tutorial:variables():getInt("TutorialSmartMaterialsCount"))
			end
			t = tutorial:variables():getInt("TutorialSmartMaterialsCounter")
			t = t - 1
			if (t == 0) then
				tutorial:variables():setBool("Tutorial_Smart_Materials", true)
				tutorial:variables():setInt("Tutorial_Smart_Materials_State", 0)
				tutorial:variables():eraseName("TutorialSmartMaterialsCounter")
				if (tutorial:variables():getInt("TutorialSmartMaterialsCount") == 1) then
					tutorial:variables():setInt("TutorialSmartMaterialsCount", 3)
				elseif (tutorial:variables():getInt("TutorialSmartMaterialsCount") == 3) then
					tutorial:variables():setInt("TutorialSmartMaterialsCount", 5)
				end
			else
				tutorial:variables():setInt("TutorialSmartMaterialsCounter", t)
			end
		end
	end
	if (tutorial:variables():findName("Tutorial_Smart_Materials")) then
		if (tutorial:variables():getInt("Tutorial_Smart_Materials_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("Tutorial_Smart_Materials_1", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("Tutorial_Smart_Materials_1")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:targetAllSawmills(0.5, Point(0, 40), 1.5)
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("Tutorial_Smart_Materials_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				if (gameInfo:getActiveBetaStat():getInt("FirstNeedMoreMaterialsHintLevel") == 0) then
					gameInfo:getActiveBetaStat():setInt("FirstNeedMoreMaterialsHintLevel", gameInfo:getLevel() + 1)
				end
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_Materials_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("Tutorial_Smart_Materials_State", 0)
				tutorial:variables():eraseName("Tutorial_Smart_Materials")
				tutorial:hideArrows(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function Tutorial_Smart_Materials_All(message)
	if (not gameInfo:getActiveBetaStat():findName("FirstNeedMoreMaterialsHintLevel")) then
		gameInfo:getActiveBetaStat():setInt("FirstNeedMoreMaterialsHintLevel", 0)
	end
	if (not tutorial:variables():findName("Tutorial_Smart_Materials_All")) then
		if (message:is("MaterialsBlock")) then
			if (not tutorial:variables():findName("TutorialSmartMaterialsAllCount")) then
				tutorial:variables():setInt("TutorialSmartMaterialsAllCount", 3) -- изначально 3 попытки
			end
			if (not tutorial:variables():findName("TutorialSmartMaterialsAllCounter")) then
				tutorial:variables():setInt("TutorialSmartMaterialsAllCounter", tutorial:variables():getInt("TutorialSmartMaterialsAllCount"))
			end
			t = tutorial:variables():getInt("TutorialSmartMaterialsAllCounter")
			t = t - 1
			if (t == 0) then
				tutorial:variables():setBool("Tutorial_Smart_Materials_All", true)
				tutorial:variables():setInt("Tutorial_Smart_Materials_All_State", 0)
				tutorial:variables():eraseName("TutorialSmartMaterialsAllCounter")
				if (tutorial:variables():getInt("TutorialSmartMaterialsAllCount") == 3) then
					tutorial:variables():setInt("TutorialSmartMaterialsAllCount", 5)
				end
			else
				tutorial:variables():setInt("TutorialSmartMaterialsAllCounter", t)
			end
		end
	end
	if (tutorial:variables():findName("Tutorial_Smart_Materials_All")) then
		if (tutorial:variables():getInt("Tutorial_Smart_Materials_All_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("Tutorial_Smart_Materials_1", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("Tutorial_Smart_Materials_1")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:targetAllSawmills(0.5, Point(0, 40), 1.5)
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("Tutorial_Smart_Materials_All_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				if (gameInfo:getActiveBetaStat():getInt("FirstNeedMoreMaterialsHintLevel") == 0) then
					gameInfo:getActiveBetaStat():setInt("FirstNeedMoreMaterialsHintLevel", gameInfo:getLevel() + 1)
				end
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_Materials_All_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("Tutorial_Smart_Materials_All_State", 0)
				tutorial:variables():eraseName("Tutorial_Smart_Materials_All")
				tutorial:hideArrows(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function Tutorial_Smart_Workers(message)
	if (not gameInfo:getActiveBetaStat():findName("NeedMoreWorkersHint")) then
		gameInfo:getActiveBetaStat():setBool("NeedMoreWorkersHint", false)
	end
	if (not tutorial:variables():findName("Tutorial_Smart_Workers")) then
		if (message:is("WorkersBlock")) then
			if (not tutorial:variables():findName("TutorialSmartWorkersCount")) then
				tutorial:variables():setInt("TutorialSmartWorkersCount", 1) -- изначально 1 попытка
			end
			if (not tutorial:variables():findName("TutorialSmartWorkersCounter")) then
				tutorial:variables():setInt("TutorialSmartWorkersCounter", tutorial:variables():getInt("TutorialSmartWorkersCount"))
			end
			t = tutorial:variables():getInt("TutorialSmartWorkersCounter")
			t = t - 1
			if (t == 0) then
				tutorial:variables():setBool("Tutorial_Smart_Workers", true)
				tutorial:variables():setInt("Tutorial_Smart_Workers_State", 0)
				tutorial:variables():eraseName("TutorialSmartWorkersCounter")
				if (tutorial:variables():getInt("TutorialSmartWorkersCount") == 1) then
					tutorial:variables():setInt("TutorialSmartWorkersCount", 3)
				elseif (tutorial:variables():getInt("TutorialSmartWorkersCount") == 3) then
					tutorial:variables():setInt("TutorialSmartWorkersCount", 3)
				end
			else
				tutorial:variables():setInt("TutorialSmartWorkersCounter", t)
			end
		end
	end
	if (tutorial:variables():findName("Tutorial_Smart_Workers")) then
		if (tutorial:variables():getInt("Tutorial_Smart_Workers_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("L_2_2_9", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("L_2_2_9")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:targetBase(0.5, Point(0, 40), 1.5)
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("Tutorial_Smart_Workers_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				gameInfo:getActiveBetaStat():setBool("NeedMoreWorkersHint", true)
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_Workers_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("Tutorial_Smart_Workers_State", 0)
				tutorial:variables():eraseName("Tutorial_Smart_Workers")
				tutorial:hideArrows(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function Tutorial_Smart_Bank(message)
	if (not gameInfo:getActiveBetaStat():findName("FirstBankOverflowHintLevel")) then
		gameInfo:getActiveBetaStat():setInt("FirstBankOverflowHintLevel", 0)
	end
	if (not tutorial:variables():findName("Tutorial_Smart_Bank")) then
		if (message:is("BankOverflow") and not gameInfo:isDataSet("BankOverflowHint")) then
			tutorial:variables():setBool("Tutorial_Smart_Bank", true)
			tutorial:variables():setInt("Tutorial_Smart_Bank_State", 0)
			tutorial:variables():setInt("Tutorial_Smart_Bank_x", message:getVariables():getPoint("Position").x)
			tutorial:variables():setInt("Tutorial_Smart_Bank_y", message:getVariables():getPoint("Position").y + 40)
		end
	end
	if (tutorial:variables():findName("Tutorial_Smart_Bank")) then
		if (tutorial:variables():getInt("Tutorial_Smart_Bank_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("Tutorial_Smart_Bank", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("Tutorial_Smart_Bank")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				arrow = tutorial:addArrow()
				tutorial:variables():setInt("TutorialBankOverflowArrow", arrow)
				tutorial:getArrow(arrow):setPosition(tutorial:variables():getInt("Tutorial_Smart_Bank_x"), tutorial:variables():getInt("Tutorial_Smart_Bank_y"))
				tutorial:getArrow(arrow):setAngle(270)
				tutorial:getArrow(arrow):setShowTimer(1.5)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:variables():setInt("Tutorial_Smart_Bank_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				gameInfo:setBoolData("BankOverflowHint", true)
				gameInfo:getActiveBetaStat():setInt("FirstBankOverflowHintLevel", gameInfo:getLevel() + 1)
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_Bank_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("Tutorial_Smart_Bank_State", 2)
				tutorial:getArrow(tutorial:variables():getInt("TutorialBankOverflowArrow")):hide(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function Tutorial_Smart_ExpertTime(message)
	if (not tutorial:variables():findName("Tutorial_Smart_ExpertTime")) then
		if (message:is("BuildingBuilt") and message:getVariables():getInt("Type") == HouseType
				and not gameInfo:isDataSet("ExpertTimeHint")) then
				tutorial:variables():setBool("Tutorial_Smart_ExpertTime", true)
				tutorial:variables():setInt("Tutorial_Smart_ExpertTime_State", 0)
		elseif (message:is("NormalTime")) then
			tutorial:variables():setBool("Tutorial_Smart_ExpertTime", true)
			tutorial:variables():setInt("Tutorial_Smart_ExpertTime_State", 3)
		end
	end
	if (tutorial:variables():findName("Tutorial_Smart_ExpertTime")) then
		if (tutorial:variables():getInt("Tutorial_Smart_ExpertTime_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("Tutorial_Smart_ExpertTime2", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("Tutorial_Smart_ExpertTime2")
					tutorial:setCharacter("Sedrik")
					tutorial:variables():setFloat("TutorialShowDelayTime", 1.0)
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				arrow = tutorial:addArrow()
				tutorial:variables():setInt("TutorialExpertTimeArrow", arrow)
				tutorial:getArrow(arrow):setPosition(30, 650)
				tutorial:getArrow(arrow):setAngle(180)
				if (tutorial:isShowing()) then
					tutorial:getArrow(arrow):setShowTimer(1.5)
				else
					tutorial:getArrow(arrow):setShowTimer(3.25)
				end
				tutorial:getArrow(arrow):setScale(1.25)
				tutorial:getArrow(arrow):show(0.5)
				tutorial:show(0.25)
				tutorial:variables():setInt("Tutorial_Smart_ExpertTime_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				gameInfo:setBoolData("ExpertTimeHint", true)
			elseif (message:is("NormalTime")) then
				tutorial:variables():setInt("Tutorial_Smart_ExpertTime_State", 3)
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_ExpertTime_State") == 1) then
			if (message:is("TutorialOk", "press") or message:is("NormalTime")) then
				tutorial:variables():setInt("Tutorial_Smart_ExpertTime_State", 3)
				tutorial:getArrow(tutorial:variables():getInt("TutorialExpertTimeArrow")):hide(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function Tutorial_Smart_Expert(message)
	if (not gameInfo:getActiveBetaStat():findName("FirstExpertTimeHintLevel")) then
		gameInfo:getActiveBetaStat():setInt("FirstExpertTimeHintLevel", 0)
	end
	if (not tutorial:variables():findName("Tutorial_Smart_Expert")) then
		if (message:is("NormalTime") and not gameInfo:isDataSet("ExpertHint")) then
			tutorial:variables():setBool("Tutorial_Smart_Expert", true)
			tutorial:variables():setInt("Tutorial_Smart_Expert_State", 0)
		end
	end
	if (tutorial:variables():findName("Tutorial_Smart_Expert")) then
		if (tutorial:variables():getInt("Tutorial_Smart_Expert_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("Tutorial_Smart_Expert1", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("Tutorial_Smart_Expert1")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("Tutorial_Smart_Expert_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				gameInfo:setBoolData("ExpertHint", true)
				gameInfo:getActiveBetaStat():setInt("FirstExpertTimeHintLevel", gameInfo:getLevel() + 1)
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_Expert_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:switchText("Tutorial_Smart_Expert2", 0.5)
				tutorial:variables():setInt("Tutorial_Smart_Expert_State", 2)
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_Expert_State") == 2) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("Tutorial_Smart_Expert_State", 3)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end


function Tutorial_Smart_ZeroTaxers(message)
	if (not gameInfo:getActiveBetaStat():findName("FirstZeroTaxersHintLevel")) then
		gameInfo:getActiveBetaStat():setInt("FirstZeroTaxersHintLevel", 0)
	end
	if (not tutorial:variables():findName("Tutorial_Smart_ZeroTaxers")) then
		if (not gameInfo:isDataSet("ZeroTaxersHint") and message:is("Update") and
			tutorial:game():getTaxersCount() == 0 and
			tutorial:game():getTaxersQueueSize() > 0) then
			tutorial:variables():setBool("Tutorial_Smart_ZeroTaxers", true)
			tutorial:variables():setInt("Tutorial_Smart_ZeroTaxers_State", 0)
		end
	end
	if (tutorial:variables():findName("Tutorial_Smart_ZeroTaxers")) then
		if (tutorial:variables():getInt("Tutorial_Smart_ZeroTaxers_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("Tutorial_Smart_ZeroTaxers", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("Tutorial_Smart_ZeroTaxers")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("Tutorial_Smart_ZeroTaxers_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				tutorial:targetBase(0.5, Point(0, 40), 1.5)
				gameInfo:setBoolData("ZeroTaxersHint", true)
				gameInfo:getActiveBetaStat():setInt("FirstZeroTaxersHintLevel", gameInfo:getLevel() + 1)
				gameInfo:savePlayerData()
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_ZeroTaxers_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("Tutorial_Smart_ZeroTaxers_State", 2)
				tutorial:hideArrows(0.25)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end


function Tutorial_Smart_MoreTaxers(message)
	if (not gameInfo:getActiveBetaStat():findName("FirstMoreTaxersHintLevel")) then
		gameInfo:getActiveBetaStat():setInt("FirstMoreTaxersHintLevel", 0)
		gameInfo:getActiveBetaStat():setInt("SecondMoreTaxersHintLevel", 0)
	end
	if (not tutorial:variables():findName("Tutorial_Smart_MoreTaxers")) then
		if (not gameInfo:isDataSet("MoreTaxersHint") and message:is("Update") and (tutorial:game():getTaxersCount() > 0)) then
			if (tutorial:game():getTaxersQueueSize() > 0) then
				t = tutorial:variables():getFloat("Tutorial_Smart_MoreTaxers_Time")
				t = t + message:getVariables():getFloat("TimeDelta")
				tutorial:variables():setFloat("Tutorial_Smart_MoreTaxers_Time", t)
				if ((
						(gameInfo:isDataSet("PreMoreTaxersHint")) and
						(t > (2 * tutorial:game():getMoreTaxersTime())) and
						(gameInfo:getIntData("PreMoreTaxersHint") ~= (gameInfo:getLevel()+1))
					) or
					(
						not gameInfo:isDataSet("PreMoreTaxersHint") and (t > tutorial:game():getMoreTaxersTime()))
					) then
					tutorial:variables():setBool("Tutorial_Smart_MoreTaxers", true)
					tutorial:variables():setInt("Tutorial_Smart_MoreTaxers_State", 0)
				end
			else
				tutorial:variables():setFloat("Tutorial_Smart_MoreTaxers_Time", 0.0)
			end
		end
	end
	if (tutorial:variables():findName("Tutorial_Smart_MoreTaxers")) then
		if (tutorial:variables():getInt("Tutorial_Smart_MoreTaxers_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("Tutorial_Smart_MoreTaxers", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("Tutorial_Smart_MoreTaxers")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("Tutorial_Smart_MoreTaxers_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				if (not gameInfo:isDataSet("PreMoreTaxersHint")) then
					gameInfo:setIntData("PreMoreTaxersHint", gameInfo:getLevel()+1)
					gameInfo:getActiveBetaStat():setInt("FirstMoreTaxersHintLevel", gameInfo:getLevel() + 1)
				else
					gameInfo:setBoolData("MoreTaxersHint", true)
					gameInfo:getActiveBetaStat():setInt("SecondMoreTaxersHintLevel", gameInfo:getLevel() + 1)
				end
				gameInfo:savePlayerData()
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_MoreTaxers_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("Tutorial_Smart_MoreTaxers_State", 0)
				tutorial:variables():eraseName("Tutorial_Smart_MoreTaxers")
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end

function Tutorial_Smart_MoneyLost(message)
	if (not gameInfo:getActiveBetaStat():findName("FirstMoneyLostHintLevel")) then
		gameInfo:getActiveBetaStat():setInt("FirstMoneyLostHintLevel", 0)
	end
	if (not tutorial:variables():findName("Tutorial_Smart_MoneyLost")) then
		if (not gameInfo:isDataSet("MoneyLostHint") and message:is("MoneyLost")) then
			tutorial:variables():setBool("Tutorial_Smart_MoneyLost", true)
			tutorial:variables():setInt("Tutorial_Smart_MoneyLost_State", 0)
		end
	end
	if (tutorial:variables():findName("Tutorial_Smart_MoneyLost")) then
		if (tutorial:variables():getInt("Tutorial_Smart_MoneyLost_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock")) then
				if (tutorial:isShowing()) then
					tutorial:switchText("Tutorial_Smart_MoneyLost", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("Tutorial_Smart_MoneyLost")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("Tutorial_Smart_MoneyLost_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				gameInfo:setBoolData("MoneyLostHint", true)
				gameInfo:getActiveBetaStat():setInt("FirstMoneyLostHintLevel", gameInfo:getLevel() + 1)
				gameInfo:savePlayerData()
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_MoneyLost_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:switchText("Tutorial_Smart_MoneyLost2", 0.5)
				tutorial:variables():setInt("Tutorial_Smart_MoneyLost_State", 2)
			end
		elseif (tutorial:variables():getInt("Tutorial_Smart_MoneyLost_State") == 2) then
			if (message:is("TutorialOk", "press")) then
				tutorial:variables():setInt("Tutorial_Smart_MoneyLost_State", 3)
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end


function Tutorial_Destroy_Sawmill(message)
	if (not gameInfo:getActiveBetaStat():findName("DestroySawmillHint")) then
		gameInfo:getActiveBetaStat():setBool("DestroySawmillHint", false)
	end
	if (not tutorial:variables():findName("Tutorial_Destroy_Sawmill") and tutorial:game():getFreeFieldsCount() == 0 and
		tutorial:getSawmillsCount() > 1 and message:is("Update") and not tutorial:variables():getBool("TutorialLock")) then
		if (not tutorial:variables():findName("TutorialDestroySawmillTime")) then
			tutorial:variables():setFloat("TutorialDestroySawmillTime", 20.0)
		end
		tutorial:variables():setFloat("TutorialDestroySawmillTime", tutorial:variables():getFloat("TutorialDestroySawmillTime") - message:getVariables():getFloat("TimeDelta"))
		if (tutorial:variables():getFloat("TutorialDestroySawmillTime") < 0.0) then
			tutorial:variables():setInt("Tutorial_Destroy_Sawmill_Ready", 1)
			tutorial:variables():eraseName("TutorialDestroySawmillTime")
		end
	end
	if (tutorial:variables():findName("Tutorial_Destroy_Sawmill_Ready")) then
		tutorial:variables():setBool("Tutorial_Destroy_Sawmill", true)
		tutorial:variables():setInt("Tutorial_Destroy_Sawmill_State", 0)
		tutorial:variables():eraseName("Tutorial_Destroy_Sawmill_Ready")
	end
	if (tutorial:variables():findName("Tutorial_Destroy_Sawmill")) then
		if (tutorial:variables():getInt("Tutorial_Destroy_Sawmill_State") == 0) then
			if (not tutorial:variables():getBool("TutorialLock") and tutorial:isAllSawmillsFree()) then
				if (tutorial:isShowing()) then
					tutorial:switchText("Tutorial_Smart_SawmillDestroy1", 0.5)
					tutorial:switchCharacter("Sedrik")
				else
					tutorial:setText("Tutorial_Smart_SawmillDestroy1")
					tutorial:setCharacter("Sedrik")
				end
				tutorial:variables():eraseName("Clickable")
				tutorial:setWidgetVisible("TutorialOk", true)
				tutorial:show(0.25)
				tutorial:variables():setInt("Tutorial_Destroy_Sawmill_State", 1)
				tutorial:variables():setBool("TutorialLock", true)
				gameInfo:getActiveBetaStat():setBool("DestroySawmillHint", true)
			elseif (message:is("Update") and (tutorial:getSawmillsCount() <= 1 or tutorial:game():getFreeFieldsCount() >= 1)) then
				tutorial:variables():setInt("Tutorial_Destroy_Sawmill_State", 0)
				tutorial:variables():eraseName("Tutorial_Destroy_Sawmill")
			end
		elseif (tutorial:variables():getInt("Tutorial_Destroy_Sawmill_State") == 1) then
			if (message:is("TutorialOk", "press")) then
				tutorial:setWidgetVisible("TutorialOk", false)
				tutorial:variables():setInt("Tutorial_Destroy_Sawmill_State", 2)
				tutorial:switchText("Tutorial_Smart_SawmillDestroy2", 0.5)
				tutorial:clearSelection()
				tutorial:variables():setInt("SawmillDestroyArrowBase", tutorial:targetAllSawmillObjects(0.5, Point(0, 40), 2.5))
			end
		elseif (tutorial:variables():getInt("Tutorial_Destroy_Sawmill_State") == 2) then
			if (message:is("Update")) then
				if (tutorial:game():getSelected()) then
					id = tutorial:game():getSelected():id()
					tutorial:hideArrows(0.25)
					tutorial:variables():setInt("TutorialActiveArrow", tutorial:variables():getInt("SawmillDestroyArrowBase") + tutorial:getSawmillArrow(id))
					tutorial:variables():setInt("DestroySawmillId", id)
					tutorial:variables():setInt("Tutorial_Destroy_Sawmill_State", 3)
					tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):moveTo(950, 100, 270, 1.0, 0.5)
					tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):setShown()
					tutorial:switchText("L_2_3_7", 0.5)
					tutorial:removeObjects()
					tutorial:addInterfaceButton("Destroy")
					tutorial:variables():setBool("TutorialKeepSelection", true)
					tutorial:setSelected()					
				end
			end
		elseif (tutorial:variables():getInt("Tutorial_Destroy_Sawmill_State") == 3) then
			if (message:is("Destroy", "press") or message:is("TutorialOk", "press")) then
				tutorial:getArrow(tutorial:variables():getInt("TutorialActiveArrow")):hide(0.25)
				tutorial:variables():setBool("TutorialKeepSelection", false)
				tutorial:unsetSelected()
				tutorial:removeInterfaceButton("Destroy")
				tutorial:variables():setInt("Tutorial_Destroy_Sawmill_State", 0)
				tutorial:variables():eraseName("Tutorial_Destroy_Sawmill")
				tutorial:hide(0.25)
				tutorial:variables():setBool("TutorialLock", false)
			end
		end
	end
end


IncludeLuaFile("Tutorial/REATutorial.lua")
IncludeLuaFile("Tutorial/RE2ATutorial.lua")
IncludeLuaFile("Tutorial/RE2ATutorial_SmartHintsBase.lua")
IncludeLuaFile("Tutorial/RE2ATutorial_SmartHints.lua")