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,40 +1,27 @@
|
||||||
GemStacker = LibStub('AceAddon-3.0'):NewAddon('GemStacker','AceConsole-3.0','AceEvent-3.0');
|
GemStacker = LibStub('AceAddon-3.0'):NewAddon('GemStacker','AceConsole-3.0','AceEvent-3.0');
|
||||||
local core = GemStacker;
|
local core = GemStacker;
|
||||||
core.gems = {};
|
|
||||||
core.lastGem = false;
|
|
||||||
|
|
||||||
function core:OnInitialize()
|
function core:OnInitialize()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:OnEnable()
|
function core:OnEnable()
|
||||||
core.gems['Puissant Dream Emerald'] = true;
|
|
||||||
|
|
||||||
--use chat_msg_loot later
|
--use chat_msg_loot later
|
||||||
self:RegisterEvent('UNIT_SPELLCAST_SUCCEEDED','FindGemCast');
|
self:RegisterEvent('CHAT_MSG_LOOT','StackGems');
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:FindGemCast(_,unitId,spell,...)
|
function core:StackGems(_,message)
|
||||||
print('GemStacker: Casted ',spell);
|
|
||||||
--should receive something like "player","Reckless Ember Topaz","",2,73369
|
--should receive something like "player","Reckless Ember Topaz","",2,73369
|
||||||
if(unitId ~= 'player') then return end;
|
if(not string.find(message,'You create')) then return end;
|
||||||
if(not core.gems[spell]) then return end;
|
local gem = message:match("%[(.-)%]");
|
||||||
|
|
||||||
core.lastGem = spell;
|
|
||||||
self:RegisterEvent('BAG_UPDATE','StackGem');
|
|
||||||
end
|
|
||||||
|
|
||||||
function core:StackGem(...)
|
|
||||||
print('GemStacker: StackGem');
|
|
||||||
if(not core.lastGem) then return end;
|
|
||||||
|
|
||||||
local sourceContainer,sourceSlot,destContainer,destSlot = -1,-1,-1,-1;
|
local sourceContainer,sourceSlot,destContainer,destSlot = -1,-1,-1,-1;
|
||||||
for bag = 0,4 do
|
for bag = 0,4 do
|
||||||
for slot = 1,GetContainerNumSlots(bag) do
|
for slot = 1,GetContainerNumSlots(bag) do
|
||||||
itemId = GetContainerItemID(bag,slot)
|
itemId = GetContainerItemID(bag,slot)
|
||||||
if(itemId) then
|
if(itemId) then
|
||||||
itemName = GetItemInfo(itemId);
|
itemName = GetItemInfo(itemId);
|
||||||
if(core.lastGem == itemName) then
|
if(gem == itemName) then
|
||||||
local _,count = GetContainerItemInfo(bag,slot);
|
local _,count = GetContainerItemInfo(bag,slot);
|
||||||
if(count == 1 and sourceContainer < 0) then
|
if(count == 1 and sourceContainer < 0) then
|
||||||
sourceContainer = bag;
|
sourceContainer = bag;
|
||||||
|
@ -51,8 +38,5 @@ function core:StackGem(...)
|
||||||
if(sourceContainer ~= -1 and destContainer ~= -1) then
|
if(sourceContainer ~= -1 and destContainer ~= -1) then
|
||||||
PickupContainerItem(sourceContainer,sourceSlot);
|
PickupContainerItem(sourceContainer,sourceSlot);
|
||||||
PickupContainerItem(destContainer,destSlot)
|
PickupContainerItem(destContainer,destSlot)
|
||||||
end
|
end
|
||||||
|
|
||||||
core.lastGem = false;
|
|
||||||
self:UnregisterEvent('BAG_UPDATE');
|
|
||||||
end
|
end
|
Loading…
Reference in a new issue