View Single Post
01-15-24, 03:57 AM   #1
Eommus
An Aku'mai Servant
Join Date: Apr 2017
Posts: 34
Displaying item level on item tooltip

Hi,

Some years ago, I used the following to display the item level on an item's tooltip (except armor and weapons and those already had item level info). But it seems it no longer works. I've been away from WoW and LUA coding for a long time, and I will appreciate any pointers to fix my code below.

Thanks!

Lua Code:
  1. local function Add_Item_Level(tooltip)
  2.     local itemLink = select(2, tooltip:GetItem())
  3.    
  4.     if itemLink ~= nil then
  5.         local itemLevel = select(4, GetItemInfo(itemLink))
  6.         local itemType = select(6, GetItemInfo(itemLink))
  7.  
  8.         if itemType ~= "Armor" and itemType ~= "Weapon" and itemLevel ~= nil then
  9.             tooltip:AppendText(" |cffffd100("..itemLevel..")")
  10.         end
  11.     end
  12. end
  13.  
  14. GameTooltip:HookScript("OnTooltipSetItem", Add_Item_Level)

EDIT 1: I learned that the API was changed. Replacing the last line with the following fixed it.

Lua Code:
  1. TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item, Add_Item_Level)

EDIT 2: But it now gives the following error for comparison item tooltips:

Lua Code:
  1. main.lua:2: attempt to call method 'GetItem' (a nil value)

I guess GetItem() was also removed but no idea what to use instead.

Last edited by Eommus : 01-15-24 at 06:50 AM.
  Reply With Quote