Thread Tools Display Modes
Prev Previous Post   Next Post Next
12-31-20, 07:29 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Get ItemID on hover

Hi all
I would like to find a way to get an itemID from an item that I am currently hovering over using a keybind.

So far I have been able to get this working by hooking the "OnTooltipSetItem" function as follows;

Lua Code:
  1. local tableOfItems, itemLink, itemID = {}, "", ""
  2.  
  3. GameTooltip:HookScript(
  4.     "OnTooltipSetItem",
  5.     function(self)
  6.         _, itemLink = self:GetItem()
  7.         if itemLink == "" or itemLink == nil then
  8.             return
  9.         else
  10.             itemID = tonumber(strmatch(itemLink, "item:(%d+):"))
  11.         end
  12.     end
  13. )
  14.  
  15. function ADDITEMTOLISTFUNCTION()
  16.     if itemLink == "" then
  17.         print("no item found")
  18.     else
  19.         addItemToList(tableOfItems, itemID)
  20.         print(itemLink, "added to list")
  21.     end
  22.     itemLink = ""
  23.     itemID = ""
  24. end

Though this does work it will pick up any item when I mouse over my bags no matter how fast I move even while not pressing the player set keybinding.

Is there a better way to get the itemID only whilst pressing the keybind?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Get ItemID on hover


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