Revert to last released version

This commit is contained in:
Andrew Tomaka 2011-07-25 14:34:44 -04:00
parent 3cebb8ffb8
commit abfc111a78

View file

@ -1,77 +1,42 @@
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;
local queue = {}
function core:OnInitialize() function core:OnInitialize()
end end
function core:OnEnable() function core:OnEnable()
self:RegisterEvent('CHAT_MSG_LOOT','TrackGems') self:RegisterEvent('CHAT_MSG_LOOT','StackGems')
self:RegisterEvent('ITEM_PUSH','StackGems')
end end
function core:TrackGems(_,message) function core:StackGems(_,message)
print('track gems') --LOOT_ITEM_CREATED_SELF = "You create: %s.";
-- Get the gem we just cut print('stack gems')
local tradeskill = message:match("%[(.-)%]") --local gem = message:match(LOOT_ITEM_CREATED_SELF)
print('found gem',gem)
local destination = {false,false}; local sourceContainer,sourceSlot,destContainer,destSlot = -1,-1,-1,-1;
-- Find the biggest, non-full stack we can find for bag = 0,NUM_BAG_SLOTS do
for bag = 0, NUM_BAG_SLOTS do for slot = 1,GetContainerNumSlots(bag) do
for slot = 1, GetContainerNumSlots(bag) do local itemId = GetContainerItemID(bag,slot)
local itemID = GetContainerItemID(bag, slot) if itemId then
if(itemID) then local itemName,_,_,_,_,_,_,maxStack = GetItemInfo(itemId);
local itemName, _, _, _, _, _, _, maxStack = GetItemInfo(itemID) if gem == itemName and maxStack ~= 1 then
local _,count = GetContainerItemInfo(bag,slot)
if tradeskill == itemName and maxStack ~= 1 then if count == 1 and sourceContainer < 0 then
local _, count = GetContainerItemInfo(bag, slot) sourceContainer = bag
sourceSlot = slot
-- Find the biggest, non-full stack we can elseif count < 20 and (count > 1 or destContainer < 0) then
if(count < maxStack) then destContainer = bag
table.insert(queue, itemID) destSlot = slot
end end
end end
end end
end end
end end
core:StackGems() if sourceContainer ~= -1 and destContainer ~= -1 then
end PickupContainerItem(sourceContainer,sourceSlot)
PickupContainerItem(destContainer,destSlot)
function core:StackGems()
print('stackgems:')
local _, stackItemID = next(queue)
if not stackItemID then return end
print('stacking gem',stackItemID)
local combineSlots = {}
for bag = 0, NUM_BAG_SLOTS do
for slot = 1, GetContainerNumSlots(bag) do
local itemID = GetContainerItemID(bag, slot)
if(itemID) then
local itemName, _, _, _, _, _, _, maxStack = GetItemInfo(itemID)
if itemID == stackItemID and maxStack ~= 1 then
print('Found', itemName,bag,slot)
local _, count = GetContainerItemInfo(bag, slot)
if count < 20 and #combineSlots < 2 then
combineSlots[#combineSlots + 1] = { bag, slot }
end
end
end
end
end
--and then stack the gems
if #combineSlots > 1 then
PickupContainerItem(combineSlots[1][1], combineSlots[1][2])
PickupContainerItem(combineSlots[2][1], combineSlots[2][2])
queue[stackItemID] = nil
elseif #combineSlots == 0 then
queue[stackItemID] = nil
end end
end end