Thread Tools Display Modes
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
03-25-24, 10:58 PM   #2
Codger
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2021
Posts: 30
Many of the item functions were moved to C_Item

Try C_Item.GetItem()
  Reply With Quote
03-26-24, 02:39 PM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
tooltip:GetItem() was replaced with TooltipUtil.GetDisplayedItem().
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 03-26-24 at 02:42 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Displaying item level on item tooltip


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off