Displaying required item level

About a year ago there was a thread over in customer support after someone complained that they no longer could see the required level in the tooltip for items that had one when they were at the level cap. Someone figured out a simple add-on to add that back to the tooltip & posted it in the thread.

With the API changes in today’s build that code no longer worked, so I got it working again & thought I would post it here as well.

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)

The only downside to this is that if you are below the required level, this code still adds it to the tooltip even though the game is already displaying it. A future improvement would be to look at the tooltip contents & figure out if it’s already being displayed or not.

it should normally only display when the player is below the value so you should be able to change

if (itemMinLevel ~= nil and itemMinLevel > 0) then

to

if ((itemMinLevel or 0) > 0 and UnitLevel( "player" ) >= itemMinLevel) then

so it only gets added once

1 Like

Thanks, that’s an easier solution than what was thinking of.

Started getting error messages when pressing the shift key to compare an item to what I’m wearing, so had to tweak it a bit more:

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
end

TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item, Add_ReqItem_Level)