Get ItemID on hover - WoWInterface
Thread Tools Display Modes
Prev Previous Post   Next Post Next
12-31-20, 07:29 PM   #1
A Flamescale Wyrmkin
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 101
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 = {}, "", ""
  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. )
  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."
  Reply With Quote

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

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