function TutorialFunc(message)
	if message == "Enter shop" then
		PermanentStorage.SetLocalBool("tutorial buy beauty", false)
		PermanentStorage.SetLocalBool("tutorial: entered shop", true)
		if PermanentStorage.GetLocalBoolOrDef("Want tutorial", true) then
			-- дальше работаем только если туториал хотят смотреть
			if not PermanentStorage.GetLocalBoolOrDef("tutorial: fish bought", false) then
				-- если рыба не была куплена, запускаем туториал ее покупки
				SendMessage("TutorialControl", "set show delay 0.5")
				SendMessage("TutorialControl", "show choose fishes tab")
			elseif PermanentStorage.GetLocalBoolOrDef("tutorial: play pressed", false) then
				if not PermanentStorage.GetLocalBoolOrDef("tutorial: beauty bought", false) then
					-- ToDo: здесь нужна бы проверка, что хватает денег
					SendMessage("TutorialControl", "set show delay 0.5")
					SendMessage("TutorialControl", "show choose beauty tab")
				else
					SendMessage("TutorialControl", "show " .. PermanentStorage.GetLocalString("last tutorial"))
				end
			else
				-- плей еще не нажимали, показываем последнее сообщение
				-- мы сюда могли войти только если во время туториала нажимали на меню, а значит last tutorial существует.
				SendMessage("TutorialControl", "show " .. PermanentStorage.GetLocalString("last tutorial"))
			end
		end
	elseif message == "Enter main screen" then		
		local levelNumber = PermanentStorage.GetLocalIntOrDef("LevelNumber", 1)
		PermanentStorage.SetLocalBool("tutorial buy beauty", false)
		if not PermanentStorage.GetLocalBoolOrDef("[want tutorial] shown", false) then
			SendMessage("TutorialControl", "show want tutorial")
			PermanentStorage.SetLocalBool("[want tutorial] shown", true)
		elseif PermanentStorage.GetLocalBoolOrDef("Want tutorial", true) then
			if not PermanentStorage.GetLocalBoolOrDef("tutorial: entered shop", false) then
				SendMessage("TutorialControl", "show enter shop")
			end
		end
	elseif message == "on put beauty" then
		-- поставили предмет - проверяем, не находимся ли в туториале
		if PermanentStorage.GetLocalBoolOrDef("tutorial buy beauty", false) then
			PermanentStorage.SetLocalBool("tutorial: beauty bought", true)
			SendMessage("TutorialControl", "set show delay 0.5")
			SendMessage("TutorialControl", "show meters")
			PermanentStorage.SetLocalBool("tutorial buy beauty", false)
		end
	elseif message == "on invalid put beauty" then
		-- поставили предмет не туда
		if PermanentStorage.GetLocalBoolOrDef("tutorial buy beauty", false) then
			PermanentStorage.SetLocalBool("tutorial: beauty bought", true)
			SendMessage("TutorialControl", "set show delay 0.5")
			SendMessage("TutorialControl", "show buy beauty")
			PermanentStorage.SetLocalBool("tutorial buy beauty", false)
		end
	elseif message == "start tutorial" then
		PermanentStorage.SetLocalBool("[want tutorial] shown", false)
		PermanentStorage.SetLocalBool("tutorial: fish bought", false)
		PermanentStorage.SetLocalBool("tutorial: beauty bought", false)
		TutorialFunc("Enter shop")
	elseif message == "want tutorial yes" then
		PermanentStorage.SetLocalBool("Want tutorial", true)
		SendMessage("TutorialControl", "show enter shop")
	elseif message == "want tutorial no" then
		SendMessage("TutorialControl", "show are you sure")
	elseif message == "are you sure yes" then
		PermanentStorage.SetLocalBool("Want tutorial", false)
	elseif message == "are you sure no" then
		PermanentStorage.SetLocalBool("Want tutorial", true)
		SendMessage("TutorialControl", "show enter shop")
	elseif message == "choose fishes tab hide" then
		SendMessage("TutorialControl", "show buy fish")
	elseif message == "buy fish hide" then
		PermanentStorage.SetLocalBool("tutorial: fish bought", true)
		SendMessage("TutorialControl", "set show delay 2.0")
		SendMessage("TutorialControl", "show after buy fish")
	elseif message == "after buy fish next" then
		SendMessage("TutorialControl", "show out of money")
	elseif message == "out of money next" then
		SendMessage("TutorialControl", "show let's play")
	elseif message == "choose beauty tab hide" then
		SendMessage("TutorialControl", "show buy beauty")
	elseif message == "buy beauty hide" then
		-- PermanentStorage.SetLocalBool("tutorial buy beauty", true)
		-- ничего не делаем, помечаем что типа находимся в туториале покупки предмета, ждём постановки предмета
	elseif message == "meters hide" then
		SendMessage("TutorialControl", "show good luck")
	elseif message == "good luck hide" then
		PermanentStorage.SetLocalBool("Want tutorial", false)
	elseif message == "skip are you sure yes" then
		PermanentStorage.SetLocalBool("Want tutorial", false)
	elseif message == "skip are you sure no" then
		PermanentStorage.SetLocalBool("Want tutorial", true)
		SendMessage("TutorialControl", "show " .. PermanentStorage.GetLocalString("last tutorial"))
	elseif message == "menu button pressed" then
		SendMessage("TutorialControl", "hide for menu")
	elseif message == "Choose tank pressed" then
		if not PermanentStorage.GetLocalBoolOrDef("tutorial: shown choose tank", false) then
			if PermanentStorage.GetLocalBoolOrDef("SetUpTutorialPause", false) then --впервый раз зашли в "chose tank"
				SendMessage("TutorialControl", "set show delay 4.0")
			else
				SendMessage("TutorialControl", "set show delay 0.5")
			end
			SendMessage("TutorialControl", "show choose tank")
			PermanentStorage.SetLocalBool("tutorial: shown choose tank", true)
		end
	elseif message == "Show photoalbum" then 
		if not PermanentStorage.GetLocalBoolOrDef("tutorial: shown photoalbum", false) then
			SendMessage("TutorialControl", "set show delay 0.5") --впервый раз зашли в фотоальбом
			if PermanentStorage.GetLocalStringOrDef("temp:PhotoAlbumPressedFrom","")=="Eye" then
				SendMessage("TutorialControl", "show photoalbumFromEye")
			else
				SendMessage("TutorialControl", "show photoalbum")
			end
			PermanentStorage.SetLocalBool("tutorial: shown photoalbum", true) 
		end
	elseif message == "shown eye" then
		if not PermanentStorage.GetLocalBoolOrDef("tutorial: shown eye", false) then
			PermanentStorage.SetLocalBool("tutorial: click on eye", true)
			PermanentStorage.SetLocalBool("tutorial: shown eye", true)
            ShowHelpSmall(400,300,"FirstEyeTooltip", 1000, 1000, 0) --впервый раз зашли в режим "глазика"
		end
	elseif string.find(message,"100percent") == 1 then
		if not PermanentStorage.GetLocalBoolOrDef("tutorial: first 100 percent", false) then
		    local name = string.sub(message,12)
		    local aX,aY = 0,0
			local wX,wY = 0,0
		    if name == "FishIndicator" then
		        aX,aY = 545,536
				wX,wY = 350,500
			elseif name == "BeautyIndicator" then
				aX,aY = 528,514
				wX,wY = 325,475 
			elseif name == "ComfortIndicator" then
				aX,aY = 515,485
				wX,wY = 300,450
			end
	        ShowHelpSmall(wX, wY,"First100Percent", aX, aY, 0) --сделай то же самое с другими показателями, и получишь бронзовый кубок
	        PermanentStorage.SetLocalBool("tutorial: first 100 percent", true)
		end
	else
		halt("Unknown message")
	end
end

function LuaTutorialMessage()
	if PermanentStorage.GetLocalBoolOrDef("temp:Start spawn game", false) then
		return false
	end
    local levelNumber = PermanentStorage.GetLocalIntOrDef("LevelNumber", 1)
	local curMode     = PermanentStorage.GetLocalStringOrDef("temp:Current mode", "menu")
    if levelNumber > 6 and curMode == "menu" and
		not PermanentStorage.GetLocalBoolOrDef("tutorial: shown choose tank", false) and
		not PermanentStorage.GetLocalBoolOrDef("tutorial: click on choose tank", false) then
		ShowHelpSmall(170,180,"MainMenuHelp5", 168, 65, -90)
	    PermanentStorage.SetLocalBool("tutorial: click on choose tank", true);
	    return true
	end
	if levelNumber > 7 and
		not PermanentStorage.GetLocalBoolOrDef("tutorial: click on eye", false) then
		ShowHelpSmall(90,325,"MainMenuHelp2", 34, 570, 90)
	    PermanentStorage.SetLocalBool("tutorial: click on eye", true);
	    return true
	end
	if levelNumber > 8 and curMode == "menu" and
		not PermanentStorage.GetLocalBoolOrDef("tutorial: shown photoalbum", false) and
		not PermanentStorage.GetLocalBoolOrDef("tutorial: click on photoalbum", false) then
		ShowHelpSmall(80,180,"MainMenuHelp4", 75, 65, -90)
	    PermanentStorage.SetLocalBool("tutorial: click on photoalbum", true)
	    return true
	end
	if curMode == "shop" and not PermanentStorage.GetLocalBoolOrDef("tutorial: shown shop", false) then
		ShowHelpSmall(622, 225, "ShopHelp1DoneButtonText", 622, 115, -90)		
		PermanentStorage.SetLocalBool("tutorial: shown shop", true)
		return true
	end
	return false
end