View Single Post
12-04-15, 07:01 PM   #5
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
It that all the code or do you have an XML file with the frame in it?

In all honesty, for a simple addon like this, you could just hook LootFrame itself.
Lua Code:
  1. local ItemList={
  2.     [774]   =true,--    Malachite
  3.     [818]   =true,--    Tigerseye
  4.     [1210]  =true,--    Shadowgem
  5. --  etc...
  6. };
  7.  
  8. LootFrame:HookScript("OnEvent",function(self,event,...)
  9.     if event=="LOOT_OPENED" then
  10.         for i=1,GetNumLootItems() do
  11.             local id=tonumber((GetLootSlotLink(i) or ""):match("|Hitem:(%d+)")) or 0;
  12.             if ItemList[id] then LootSlot(i); end
  13.         end
  14.     end
  15. end);
Note: Line 12 uses a casting method to insure id is given a number to index the lookup table. This is given the inherent behavior of X or Y in which if X evaluates to a false condition (false or nil), Y is used.



PS: From the code example, it appears to be mixed with code from vanilla WoW. Globals like this are no longer in use.
__________________
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 : 12-04-15 at 07:07 PM.
  Reply With Quote