Produce regex to check. NYF

This commit is contained in:
Andrew Tomaka 2011-07-25 16:31:34 -04:00
parent c4ac7c9032
commit 9012a4fb86

View file

@ -1,26 +1,34 @@
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 lastGem = nil
function core:OnInitialize() function core:OnInitialize()
end end
function core:OnEnable() function core:OnEnable()
self:RegisterEvent('CHAT_MSG_TRADESKILLS','StackGems') self:RegisterEvent('CHAT_MSG_TRADESKILLS','TrackGems')
end end
function core:StackGems(_,message) function core:TrackGems(_,message)
--LOOT_ITEM_CREATED_SELF = "You create: %s."; /dump LOOT_ITEM_CREATED_SELF:gsub("%%s", "(.-)") --LOOT_ITEM_CREATED_SELF = "You create: %s."; /dump TRADESKILL_LOG_FIRSTPERSON:gsub("%%s", "(.-)")
local gem = message:match(LOOT_ITEM_CREATED_SELF:gsub("%%s", "(.-)")) lastGem = message:match(TRADESKILL_LOG_FIRSTPERSON:gsub("%%s", "(.+)"))
print('found gem',gem) if lastGem == nil or lastGem == "" then return end
print('TrackGems found',lastGem)
self:RegisterEvent('ITEM_PUSH','StackGems')
end
function core:StackGems()
print('StackGems stacking',lastGem)
local sourceContainer,sourceSlot,destContainer,destSlot = -1,-1,-1,-1; local sourceContainer,sourceSlot,destContainer,destSlot = -1,-1,-1,-1;
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 if lastGem == itemName and maxStack ~= 1 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
@ -34,8 +42,12 @@ function core:StackGems(_,message)
end end
end end
print(sourceContainer,sourceSlot,destContainer,destSlot)
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
lastGem = nil
self:UnregisterEvent('ITEM_PUSH')
end end