WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Uniquely Identifying Items (https://www.wowinterface.com/forums/showthread.php?t=58223)

krel666 09-24-20 08:46 PM

Uniquely Identifying Items
 
Hey all,

I'm making an addon for Classic and need a way to uniquely identify soul shards Warlocks create in their bags. I've read through the API and couldn't really find anything. The best solution I came up with was using the bag number and slot number to map to corresponding soul shards.

This approach however ran into its own issue. I would like to use the tooltip widget to hover over a soul shard and display information unique to that specific soul shard. The problem is the tooltip functions provide no way of getting the bag index/slot index of the item you're hovering over.

I could get this information if the user selects (locks) a soul shard from the inventory, but that's not the solution I'm looking for.

Thanks!

Vrul 09-25-20 02:57 PM

If the GameTooltip is showing for an item then the mouse is still over that item so you can use GetMouseFocus:
Code:

local focus = GetMouseFocus()
if not (focus:GetName() or ""):match("ContainerFrame%d+Item%d+") then return end
local bagID, slotID = focus:GetParent():GetID(), focus:GetID()
-- Do something with bagID, slotID


krel666 09-25-20 04:06 PM

Awesome, thank you so much!

SDPhantom 09-26-20 03:28 PM

Sounds like a fun personal project I made a while ago that tracks who's soul a shard is created from.
It even shows the origin of the shard used to create healthstones, soulstones, and even summoned demons.
It also works on generic item tooltips, meaning ActionButton tooltips work.

Kanegasi 09-26-20 03:56 PM

classic has the item api retail uses, at least according to the code extract. Here's what I use in a retail weakaura to track and loot openable looted items:

Lua Code:
  1. if event=="BAG_UPDATE_DELAYED" then
  2.     if not aura_env.combat and not InCombatLockdown() then
  3.         for b=BACKPACK_CONTAINER,NUM_BAG_SLOTS do
  4.             for s=1,GetContainerNumSlots(b) do
  5.                 if GetContainerItemID(b,s)==45724 then
  6.                     aura_env[(Item:CreateFromBagAndSlot(b,s):GetItemGUID())]=1
  7.                     UseContainerItem(b,s)
  8.                 end
  9.             end
  10.         end
  11.     end
  12. elseif event=="LOOT_OPENED" then
  13.     for i=GetNumLootItems(),1,-1 do
  14.         if aura_env[(GetLootSourceInfo(i))] then
  15.             LootSlot(i)
  16.         end
  17.     end
  18. end

The bag update event opens the specific openable I'm tracking while saving that bag's GUID, then the loot opened event checks the loot source and if it's a guid I saved, autoloot it all.

JDoubleU00 09-26-20 07:08 PM

Quote:

Originally Posted by SDPhantom (Post 336900)
Sounds like a fun personal project I made a while ago that tracks who's soul a shard is created from.
It even shows the origin of the shard used to create healthstones, soulstones, and even summoned demons.
It also works on generic item tooltips, meaning ActionButton tooltips work.

That does sound like fun. It would be cool if you modified the tooltip to say "Fred's soulstone" or had random emotes saying "Let me go". :)

SDPhantom 09-27-20 04:59 AM

Quote:

Originally Posted by JDoubleU00 (Post 336904)
It would be cool if you modified the tooltip to say "Fred's soulstone"

This is pretty much what it does. :D

JDoubleU00 09-27-20 03:58 PM

Quote:

Originally Posted by SDPhantom (Post 336907)
This is pretty much what it does. :D

Would you be willing to share it? I play a warlock and this would add so much to the class play.

SDPhantom 09-28-20 02:26 AM

Sure. It's just prototype code atm. I'll get it uploaded once I get it into a more polished state.


All times are GMT -6. The time now is 08:04 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI