Mad props to you for being able to create code to fix this, and thanks for sharing it. I’m not feeling daring enough to start copy-pasting code to fix Blizzard’s shortcomings (yet). We shouldn’t have to, anyway.
1 Like
With the API changes in 10.0.2, the code needed to do this is slightly different now:
local function Add_ReqItem_Level(tooltip, data)
local _, itemLink = tooltip:GetItem()
if (itemLink ~= nil) then
local _, _, _, _, itemMinLevel = GetItemInfo(itemLink)
if (itemMinLevel ~= nil and itemMinLevel > 0) then
tooltip:AddLine("Requires Level "..itemMinLevel)
end
end
end
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item, Add_ReqItem_Level)
Edit: You can change the innermost if statement so that the item level is only added to the tooltip if it is not already being displayed:
if (itemMinLevel ~= nil and
itemMinLevel > 0 and
UnitLevel("player") >= itemMinLevel) then
1 Like
Unfortunately the new patch seems to have messed something up:
4159x ReqLevel/main.lua:2: attempt to call method 'GetItem' (a nil value)
[string "@ReqLevel/main.lua"]:2: in function <ReqLevel/main.lua:1>
[string "=(tail call)"]: ?
[string "=[C]"]: in function `securecallfunction'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:162: in function <SharedXML/Tooltip/TooltipDataHandler.lua:157>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:182: in function <SharedXML/Tooltip/TooltipDataHandler.lua:178>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:218: in function <SharedXML/Tooltip/TooltipDataHandler.lua:208>
[string "=[C]"]: in function `SetAttribute'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:243: in function <SharedXML/Tooltip/TooltipDataHandler.lua:236>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:389: in function <SharedXML/Tooltip/TooltipDataHandler.lua:339>
[string "=[C]"]: in function `securecallfunction'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:336: in function `ProcessInfo'
[string "@SharedXML/Tooltip/TooltipComparisonManager.lua"]:251: in function `SetItemTooltip'
...
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:151: in function <SharedXML/Tooltip/TooltipDataHandler.lua:146>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:173: in function <SharedXML/Tooltip/TooltipDataHandler.lua:169>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:237: in function <SharedXML/Tooltip/TooltipDataHandler.lua:236>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:389: in function <SharedXML/Tooltip/TooltipDataHandler.lua:339>
[string "=[C]"]: in function `securecallfunction'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:336: in function <SharedXML/Tooltip/TooltipDataHandler.lua:335>
[string "=(tail call)"]: ?
[string "=[C]"]: in function `SetInboxItem'
[string "@FrameXML/MailFrame.lua"]:898: in function `OpenMailAttachment_OnEnter'
[string "*MailFrame.xml:263_OnUpdate"]:2: in function <[string "*MailFrame.xml:263_OnUpdate"]:1>
Locals:
tooltip = ShoppingTooltip1 {
0 = <userdata>
ATT_AttachComplete = true
GetBackdropColor = <function> defined @SharedXML/Backdrop.lua:390
SetHyperlink = <function> defined =[C]:-1
SetAzeriteEssence = <function> defined =[C]:-1
SetVoidDepositItem = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
AllTheThingsOnTooltipClearedHook = true
SetTraitEntry = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
ClearBackdrop = <function> defined =[C]:-1
SetLootCurrency = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
SetLootItem = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
SetQuestLogSpecialItem = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
SetRecipeReagentItem = <function> defined =[C]:-1
SetMerchantItem = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
BottomOverlay = Texture {
}
SetSocketedRelic = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
ProcessInfo = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:335
NineSlice = Frame {
}
SetInventoryItem = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
TopEdge = Texture {
}
SetUnitDebuffByAuraInstanceID = <function> defined =[C]:-1
GetProcessingTooltipInfo = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:488
SetBackdropColor = <function> defined =[C]:-1
LeftEdge = Texture {
}
AddLineDataText = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:429
AppendInfo = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:525
SetSpellBookItem = <function> defined =[C]:-1
textLeft1Font = "GameFontNormalSmall"
AppendInfoWithSpacer = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:531
SetShapeshift = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
hasMoney = 1
SetArtifactPowerByID = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
textRight2Font = "GameFontHighlightSmall"
TopOverlay = Texture {
}
SetSocketedItem = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
SetUnitDebuff = <function> defined =[C]:-1
SetWorldLootObject = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
SetMountBySpellID = <function> defined =[C]:-1
SetBorderBlendMode = <function> defined @SharedXML/Backdrop.lua:266
SetTrainerService = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
TextLeft1 = ShoppingTooltip1TextLeft1 {
}
SetAzeritePower = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
SetLFGDungeonShortageReward = <function> defined =[C]:-1
OnBackdropSizeChanged = <function> defined @SharedXML/Backdrop.lua:182
ClearHandlerInfo = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:444
SetArtifactItem = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
SetPossession = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
SetAzeriteEssenceSlot = <function> defined =[C]:-1
SetUnitBuffByAuraInstanceID = <function> defined =[C]:-1
SetConduit = <function> defined =[C]:-1
SetupPieceVisuals = <function> defined @SharedXML/Backdrop.lua:246
SetMinimapMouseover = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
SetQuestLogCurrency = <function> defined =[C]:-1
SetRecipeResultItem = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
SetQuestPartyProgress = <function> defined =[C]:-1
ProcessLineData = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:410
SetText = <function> defined =[C]:-1
OnBackdropLoaded = <function> defined @SharedXML/Backdrop.lua:152
SetPvpTalent = <function> defined @SharedXML/Tooltip/TooltipDataHandler.lua:539
SetExistingSocketGem = <function> defined @SharedXML/Tooltip
It’s still working for me in 10.2.6. Are you having this error on the 10.2.7 PTR?
FWIW, here’s the code I currently have for my version:
local function Add_ReqItem_Level(tooltip)
if (tooltip ~= ShoppingTooltip1 and tooltip ~= ShoppingTooltip2) then
local _, itemLink = tooltip:GetItem()
if (itemLink ~= nil) then
local _, _, _, _, itemMinLevel = GetItemInfo(itemLink)
if (itemMinLevel ~= nil and
itemMinLevel > 0 and
UnitLevel("player") >= itemMinLevel) then
tooltip:AddLine("Requires Level "..itemMinLevel)
end
end
end
end
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item, Add_ReqItem_Level)