Lua Help - Tooltips

I’m trying to make PLH work for myself and I’ve gotten it to the point that I’m getting the following error:

69x FrameXML/GameTooltip.lua:338: attempt to concatenate a nil value
[string "@FrameXML/GameTooltip.lua"]:338: in function `SetTooltipMoney'
[string "@FrameXML/GameTooltip.lua"]:320: in function `GameTooltip_OnTooltipAddMoney'
[string "@SharedXML/Tooltip/TooltipDataRules.lua"]:137: in function `func'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:49: in function <SharedXML/Tooltip/TooltipDataHandler.lua:44>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:71: in function <SharedXML/Tooltip/TooltipDataHandler.lua:67>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:159: in function <SharedXML/Tooltip/TooltipDataHandler.lua:158>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:320: in function `ProcessLineData'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:299: in function `ProcessLines'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:276: in function <SharedXML/Tooltip/TooltipDataHandler.lua:240>
[string "=[C]"]: in function `securecallfunction'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:237: in function <SharedXML/Tooltip/TooltipDataHandler.lua:236>
[string "=(tail call)"]: ?
[string "@PersonalLootHelper/PersonalLootHelper-Core.lua"]:630: in function <...ddOns/PersonalLootHelper/PersonalLootHelper-Core.lua:607>
[string "@PersonalLootHelper/PersonalLootHelper-Core.lua"]:872: in function <...ddOns/PersonalLootHelper/PersonalLootHelper-Core.lua:865>
[string "@PersonalLootHelper/PersonalLootHelper-Core.lua"]:2418: in function <...ddOns/PersonalLootHelper/PersonalLootHelper-Core.lua:2410>
[string "@PersonalLootHelper/PersonalLootHelper-Core.lua"]:2549: in function <...ddOns/PersonalLootHelper/PersonalLootHelper-Core.lua:2536>

I’m reasonably certain the main cause is the following function resulting from the tooltip changes in 10.0.2.

tooltipLong = tooltipLong or PLH_CreateEmptyTooltip(30)
tooltipLong:ClearLines()
tooltipLong:SetHyperlink(item)

That said, I’m not certain what to replace them with, as there’s no OnTooltipSetItem handler anywhere in the existing code. Would appreciate a shove in the right direction.

local function GetFullItemInfo(item)
	local ITEM_CLASSES_ALLOWED_PATTERN									= _G.ITEM_CLASSES_ALLOWED:gsub('%%s', '(.+)')		-- Classes: (.+)
	local BIND_TRADE_TIME_REMAINING_PATTERN 							= _G.BIND_TRADE_TIME_REMAINING:gsub('%%s', '(.+)')  -- You may trade this item with players that were also eligible to loot this item for the next (.+).
	local TRANSMOGRIFY_TOOLTIP_APPEARANCE_UNKNOWN_PATTERN 				= _G.TRANSMOGRIFY_TOOLTIP_APPEARANCE_UNKNOWN:gsub('%%s', '(.+)')			-- You haven't collected this appearance
	local TRANSMOGRIFY_TOOLTIP_ITEM_UNKNOWN_APPEARANCE_KNOWN_PATTERN 	= _G.TRANSMOGRIFY_TOOLTIP_ITEM_UNKNOWN_APPEARANCE_KNOWN:gsub('%%s', '(.+)')	-- You've collected this appearance, but not from this item
	local TOOLTIP_AZERITE_UNLOCK_LEVELS_PATTERN							= _G.TOOLTIP_AZERITE_UNLOCK_LEVELS:gsub('%(0/%%d%)', '%%(0/%%d%%)')  		-- Azerite Powers (0/%d):
	local CURRENTLY_SELECTED_AZERITE_POWERS_PATTERN						= _G.CURRENTLY_SELECTED_AZERITE_POWERS:gsub('%(%%d/%%d%)', '%%(%%d/%%d%%)')	-- Active Azerite Powers (%d/%d):
	local fullItemInfo = {}

	if item ~= nil then
		fullItemInfo[FII_ITEM] = item
		
		-- determine the basic values from the Blizzard GetItemInfo() API call
		_, _, fullItemInfo[FII_QUALITY], fullItemInfo[FII_BASE_ILVL], fullItemInfo[FII_REQUIRED_LEVEL], _, _, _, fullItemInfo[FII_ITEM_EQUIP_LOC], _, _, fullItemInfo[FII_CLASS], fullItemInfo[FII_SUB_CLASS], fullItemInfo[FII_BIND_TYPE], _, _, _ = GetItemInfo(item)

		-- determine whether the item is equippable
		fullItemInfo[FII_IS_EQUIPPABLE] = IsEquippableItem(item)

		if fullItemInfo[FII_IS_EQUIPPABLE] then

			-- set up the tooltip to determine values that aren't returned via GetItemInfo()
			tooltipLong = tooltipLong or PLH_CreateEmptyTooltip(30)
			tooltipLong:ClearLines()
			tooltipLong:SetHyperlink(item)

			-- determine the real iLVL
			local realILVL = GetILVLFromTooltip(tooltipLong)
			if realILVL == nil then  -- if we still couldn't find it (shouldn't happen), just use the base ilvl we got from GetItemInfo()
				realILVL = fullItemInfo[FII_BASE_ILVL]
			end
			fullItemInfo[FII_REAL_ILVL] = tonumber(realILVL)

			local classes = nil
			local hasBindTradeTimeWarning = nil
			local hasSocket = false
			local hasAvoidance = false
			local hasIndestructible = false
			local hasLeech = false
			local hasSpeed = false
			local xmoggable = false
			local isAzeriteItem = false
			local text

			local index = 6 -- the elements we're looking for are all further down in the tooltip
			while tooltipLong.leftside[index] do
				text = tooltipLong.leftside[index]:GetText()
				if text ~= nil then
					hasBindTradeTimeWarning = hasBindTradeTimeWarning or text:match(BIND_TRADE_TIME_REMAINING_PATTERN)
					classes = classes or text:match(ITEM_CLASSES_ALLOWED_PATTERN)
					hasSocket = hasSocket or text:find(_G.EMPTY_SOCKET_PRISMATIC) == 1
					hasAvoidance = hasAvoidance or text:find(_G.STAT_AVOIDANCE) ~= nil
					hasIndestructible = hasIndestructible or text:find(_G.STAT_STURDINESS) == 1
					hasLeech = hasLeech or text:find(_G.STAT_LIFESTEAL) ~= nil
					hasSpeed = hasSpeed or text:find(_G.STAT_SPEED) ~= nil
					xmoggable = xmoggable or text:find(TRANSMOGRIFY_TOOLTIP_APPEARANCE_UNKNOWN_PATTERN) ~= nil or text:find(TRANSMOGRIFY_TOOLTIP_ITEM_UNKNOWN_APPEARANCE_KNOWN_PATTERN) ~= nil
					isAzeriteItem = isAzeriteItem or text:match(TOOLTIP_AZERITE_UNLOCK_LEVELS_PATTERN) ~= nil or text:match(CURRENTLY_SELECTED_AZERITE_POWERS_PATTERN) ~= nil
				end
				index = index + 1
			end

			if classes ~= nil then
				classes = string.upper(classes)
				classes = string.gsub(classes, ' ', '')  -- remove space for DEMON HUNTER, DEATH KNIGHT
			end

--			if hasBindTradeTimeWarning then
--				print("SETTING FII_TRADE_TIME_WARNING_SHOWN TO TRUE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
--			end

			fullItemInfo[FII_CLASSES] = classes
			fullItemInfo[FII_TRADE_TIME_WARNING_SHOWN] = hasBindTradeTimeWarning
			fullItemInfo[FII_HAS_SOCKET] = hasSocket
			fullItemInfo[FII_HAS_AVOIDANCE] = hasAvoidance
			fullItemInfo[FII_HAS_INDESTRUCTIBLE] = hasIndestructible
			fullItemInfo[FII_HAS_LEECH] = hasLeech
			fullItemInfo[FII_HAS_SPEED] = hasSpeed
			fullItemInfo[FII_XMOGGABLE] = xmoggable
			fullItemInfo[FII_IS_AZERITE_ITEM] = isAzeriteItem
		end
	end

	return fullItemInfo
end
function PLH_CreateEmptyTooltip(rows)
    local tooltip = CreateFrame('GameTooltip', nil, nil, GameTooltipDataMixin and "GameTooltipTemplate")
	local leftside = {}
	local rightside = {}
	local L, R
    for i = 1, rows do
        L, R = tooltip:CreateFontString(), tooltip:CreateFontString()
        L:SetFontObject(GameFontNormal)
        R:SetFontObject(GameFontNormal)
        tooltip:AddFontStrings(L, R)
        leftside[i] = L
		rightside[i] = R
    end
    tooltip.leftside = leftside
	tooltip.rightside = rightside
	tooltip:SetOwner(UIParent, 'ANCHOR_NONE')
    return tooltip
end
function PLH_CreateEmptyTooltip(rows)
    local tooltip = CreateFrame('GameTooltip', "GiveTheTooltipaUniqueName", nil, GameTooltipDataMixin and
1 Like

One down.

1x PLHTooltipMoneyFrame1:SetPoint(): Couldn't find region named 'PLHTooltipTextLeft12'
[string "=[C]"]: in function `SetPoint'
[string "@FrameXML/GameTooltip.lua"]:358: in function `SetTooltipMoney'
[string "@FrameXML/GameTooltip.lua"]:320: in function `GameTooltip_OnTooltipAddMoney'
[string "@SharedXML/Tooltip/TooltipDataRules.lua"]:137: in function `func'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:49: in function <SharedXML/Tooltip/TooltipDataHandler.lua:44>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:71: in function <SharedXML/Tooltip/TooltipDataHandler.lua:67>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:159: in function <SharedXML/Tooltip/TooltipDataHandler.lua:158>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:320: in function `ProcessLineData'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:299: in function `ProcessLines'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:276: in function <SharedXML/Tooltip/TooltipDataHandler.lua:240>
[string "=[C]"]: in function `securecallfunction'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:237: in function <SharedXML/Tooltip/TooltipDataHandler.lua:236>
[string "=(tail call)"]: ?
[string "@PersonalLootHelper/PersonalLootHelper-Core.lua"]:630: in function <...ddOns/PersonalLootHelper/PersonalLootHelper-Core.lua:607>
[string "@PersonalLootHelper/PersonalLootHelper-Core.lua"]:872: in function <...ddOns/PersonalLootHelper/PersonalLootHelper-Core.lua:865>
[string "@PersonalLootHelper/PersonalLootHelper-Core.lua"]:2418: in function <...ddOns/PersonalLootHelper/PersonalLootHelper-Core.lua:2410>
[string "@PersonalLootHelper/PersonalLootHelper-Core.lua"]:2549: in function <...ddOns/PersonalLootHelper/PersonalLootHelper-Core.lua:2536>

Locals:
(*temporary) = PLHTooltipMoneyFrame1 {
 GoldButton = PLHTooltipMoneyFrame1GoldButton {
 }
 PrefixText = PLHTooltipMoneyFrame1PrefixText {
 }
 trialErrorButton = PLHTooltipMoneyFrame1TrialErrorButton {
 }
 CopperButton = PLHTooltipMoneyFrame1CopperButton {
 }
 moneyType = "STATIC"
 info = <table> {
 }
 0 = <userdata>
 small = 1
 SilverButton = PLHTooltipMoneyFrame1SilverButton {
 }
 SuffixText = PLHTooltipMoneyFrame1SuffixText {
 }
}
(*temporary) = "LEFT"
(*temporary) = "PLHTooltipTextLeft12"
(*temporary) = "LEFT"
(*temporary) = 4
(*temporary) = 0

The GameTooltipTemplate structure will have changed so there’s no Fontstring with the “$parentTextLeft12” name. I’m not sure what it uses to replace this off the top of my head.

Whelp, despite those errors it seems to be functioning now. Thanks for the help!

Looks like it’s 2-4 lines now?
https://github.com/Gethe/wow-ui-source/blob/live/Interface/FrameXML/GameTooltip.xml#L111

I thought your original post said TextLeft2.

It’s a bit hard to tell without knowing which setpoint call is causing the error and the code around it that comes up with the 12 figure (I’ve never used PLH).

PLH_CreateEmptyTooltip is creating a tooltip with 30 rows and setting font strings to left/right on each of em.

Slapped it up on GitHub

Line 65 in PersonalLootHelper-Util.lua change:

L, R = tooltip:CreateFontString(), tooltip:CreateFontString()

to:

L, R = tooltip:CreateFontString("$parentTextLeft"..i), tooltip:CreateFontString("$parentTextRight"..i)
1 Like

Oh, that was way easier than the route I was going down lol.

Was going to switch it over to C_TooltipInfo.GetHyperlink()

Why they started using frame names rather than parentKeys for these I don’t know. Maybe just to make people like me feel useful :rofl:

Then again, I haven’t really looked into the tooltip changes because (so far) I haven’t needed to.

Running error free now. Thanks for all the help Fizzle! :slight_smile:

2 Likes