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:
local ItemList={
[774] =true,-- Malachite
[818] =true,-- Tigerseye
[1210] =true,-- Shadowgem
-- etc...
};
LootFrame:HookScript("OnEvent",function(self,event,...)
if event=="LOOT_OPENED" then
for i=1,GetNumLootItems() do
local id=tonumber((GetLootSlotLink(i) or ""):match("|Hitem:(%d+)")) or 0;
if ItemList[id] then LootSlot(i); end
end
end
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.