Use CHAT_MSG_LOOT as event.
This commit is contained in:
parent
e10f186b3c
commit
5e8578454a
1 changed files with 6 additions and 22 deletions
|
@ -1,32 +1,19 @@
|
|||
GemStacker = LibStub('AceAddon-3.0'):NewAddon('GemStacker','AceConsole-3.0','AceEvent-3.0');
|
||||
local core = GemStacker;
|
||||
core.gems = {};
|
||||
core.lastGem = false;
|
||||
|
||||
function core:OnInitialize()
|
||||
|
||||
end
|
||||
|
||||
function core:OnEnable()
|
||||
core.gems['Puissant Dream Emerald'] = true;
|
||||
|
||||
--use chat_msg_loot later
|
||||
self:RegisterEvent('UNIT_SPELLCAST_SUCCEEDED','FindGemCast');
|
||||
self:RegisterEvent('CHAT_MSG_LOOT','StackGems');
|
||||
end
|
||||
|
||||
function core:FindGemCast(_,unitId,spell,...)
|
||||
print('GemStacker: Casted ',spell);
|
||||
function core:StackGems(_,message)
|
||||
--should receive something like "player","Reckless Ember Topaz","",2,73369
|
||||
if(unitId ~= 'player') then return end;
|
||||
if(not core.gems[spell]) then return end;
|
||||
|
||||
core.lastGem = spell;
|
||||
self:RegisterEvent('BAG_UPDATE','StackGem');
|
||||
end
|
||||
|
||||
function core:StackGem(...)
|
||||
print('GemStacker: StackGem');
|
||||
if(not core.lastGem) then return end;
|
||||
if(not string.find(message,'You create')) then return end;
|
||||
local gem = message:match("%[(.-)%]");
|
||||
|
||||
local sourceContainer,sourceSlot,destContainer,destSlot = -1,-1,-1,-1;
|
||||
for bag = 0,4 do
|
||||
|
@ -34,7 +21,7 @@ function core:StackGem(...)
|
|||
itemId = GetContainerItemID(bag,slot)
|
||||
if(itemId) then
|
||||
itemName = GetItemInfo(itemId);
|
||||
if(core.lastGem == itemName) then
|
||||
if(gem == itemName) then
|
||||
local _,count = GetContainerItemInfo(bag,slot);
|
||||
if(count == 1 and sourceContainer < 0) then
|
||||
sourceContainer = bag;
|
||||
|
@ -52,7 +39,4 @@ function core:StackGem(...)
|
|||
PickupContainerItem(sourceContainer,sourceSlot);
|
||||
PickupContainerItem(destContainer,destSlot)
|
||||
end
|
||||
|
||||
core.lastGem = false;
|
||||
self:UnregisterEvent('BAG_UPDATE');
|
||||
end
|
Loading…
Reference in a new issue