View Single Post
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