Thread Tools Display Modes
09-24-20, 08:46 PM   #1
krel666
A Murloc Raider
Join Date: Sep 2020
Posts: 5
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!
  Reply With Quote
09-25-20, 02:57 PM   #2
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
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
  Reply With Quote
09-25-20, 04:06 PM   #3
krel666
A Murloc Raider
Join Date: Sep 2020
Posts: 5
Awesome, thank you so much!
  Reply With Quote
09-26-20, 03:28 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,308
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.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 09-26-20 at 03:38 PM.
  Reply With Quote
09-26-20, 03:56 PM   #5
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
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.
  Reply With Quote
09-26-20, 07:08 PM   #6
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
Originally Posted by SDPhantom View Post
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".
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote
09-27-20, 04:59 AM   #7
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,308
Originally Posted by JDoubleU00 View Post
It would be cool if you modified the tooltip to say "Fred's soulstone"
This is pretty much what it does.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
09-27-20, 03:58 PM   #8
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
Originally Posted by SDPhantom View Post
This is pretty much what it does.
Would you be willing to share it? I play a warlock and this would add so much to the class play.
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote
09-28-20, 02:26 AM   #9
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,308
Sure. It's just prototype code atm. I'll get it uploaded once I get it into a more polished state.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Uniquely Identifying Items

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