From 91bfed75ed7f94caf47720e085563fe4b5044a2a Mon Sep 17 00:00:00 2001 From: atomaka Date: Wed, 29 Jun 2011 08:30:30 -0400 Subject: [PATCH] Basic LUA implementation --- GemStacker.lua | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/GemStacker.lua b/GemStacker.lua index acd6097..a531d0f 100644 --- a/GemStacker.lua +++ b/GemStacker.lua @@ -6,23 +6,33 @@ function core:OnInitialize() end function core:OnEnable() - self:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED','CheckGemCut'); + self:RegisterEvent('UNIT_SPELLCAST_SUCCEEDED','StackGem'); end -function core:CheckGemCut(_,event,_,sourceGUID,sourceName,_,_,_,_,_,_,spellSchool) - if(not gemCasts[spellSchool]) then return end; +function core:StackGem(unitID,spell,rank,lineID,spellID) + --should receive something like "player","Reckless Ember Topaz","",2,73369 + if(unitID ~= 'player') then return end; + if(not gems[spellID]) then return end; - self:RegisterEvent('BAG_UPDATE','StackGem'); -end + --go through all bag slots and find all stacks of this gem type. + --local sourceStack = {}; + --local destStack = {}; + --for all of the bags + -- for all of the slots + -- if(gems[spellID] == GetContainerItemID(1,11)) then + -- _,count = GetContainerItemInfo(container, slot) + -- if(count == 1) then + -- sourceStack = {container,slot); + -- elseif(count < 20) then + -- destStack = {container,slot); + -- end + -- end + -- end + --end -function core:StackGem(container) - --find the item (tricky?) - - --check all bags to see if there is an existing stack - - --if there is an existing stack and it is not max, stack the new gem on the old stack - - self:UnregisterEvent('BAG_UDATE'); + --if there is a stack of 1 and a stack of < 20, combine them + PickupContainerItem(sourceStack[0],sourceStack[1]) + PickupContainerItem(destStack[0],destStack[1]) end --BAG_UPDATE - container