Thread Tools Display Modes
07-05-17, 04:22 AM   #1
Eommus
An Aku'mai Servant
Join Date: Apr 2017
Posts: 34
Custom tooltip text not displaying for Tradeskill window items I don't possess

Hi,

I use the following code to display the "item level" of an item (all items except armor and weapon) next to its name. Ex: "Heavy Kodo Stew (35)".

Lua Code:
  1. local function Add_Item_Level(tooltip)
  2.     local item = tooltip:GetItem()
  3.    
  4.     if item ~= nil then
  5.         local itemLevel = select(4, GetItemInfo(item))
  6.         local itemType = select(6, GetItemInfo(item))
  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)

When I open a profession window (e.g. Blacksmithing) and bring the cursor over a resulting item, the item level is displayed only for items that I posses. For example, I have Dense Grinding Stone, its item level is displayed:

http://imgur.com/kTrxxbP

On the other hand, I don't have Heavy Grinding Stone, its item level is not displayed:

http://imgur.com/8GwaR95

Any ideas why it is not displaying on items I don't have, and how to make it display?

Thanks.
  Reply With Quote
07-05-17, 05:36 AM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
First return from tooltip:GetItem() is the item name, which only works with GetItemInfo if you have the item in question. Use the second return, item link, instead.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
07-06-17, 01:39 AM   #3
Eommus
An Aku'mai Servant
Join Date: Apr 2017
Posts: 34
Originally Posted by Lombra View Post
First return from tooltip:GetItem() is the item name, which only works with GetItemInfo if you have the item in question. Use the second return, item link, instead.
Thank you very much! I modified it like the following and it displays the item level for items I don't have too.

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)

Last edited by Eommus : 07-06-17 at 01:42 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Custom tooltip text not displaying for Tradeskill window items I don't possess

Thread Tools
Display Modes

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