WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Custom tooltip text not displaying for Tradeskill window items I don't possess (https://www.wowinterface.com/forums/showthread.php?t=55547)

Eommus 07-05-17 04:22 AM

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.

Lombra 07-05-17 05:36 AM

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.

Eommus 07-06-17 01:39 AM

Quote:

Originally Posted by Lombra (Post 324092)
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)


All times are GMT -6. The time now is 12:43 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI