WoWInterface SVN kRestack

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 13 to Rev 12
    Reverse comparison

Rev 13 → Rev 12

kRestack/changelog.txt File deleted \ No newline at end of file
kRestack/kRestack.lua
1,33 → 1,18
--[[ kRestack() is a global function and can be used in any addon or macro
Some of the functionality is based on ArkInventory's restacking function, kudos!
 
Usage: /restack [bags, bank, auto]
Devs: kRestack("bags") and kRestack("bank") can be used in your addons. ]]
Usage: /restack [bags, bank, auto] ]]
 
SlashCmdList["RESTACK"] = function(s) kRestack(s) end
SLASH_RESTACK1 = "/restack"
 
--[[ insert backpack and default bank container ]]
local container = { bags = { 0 }, bank = { -1 } }
 
--[[ initialize user's bag and bank identifiers ]]
for i = 1, NUM_BAG_SLOTS do table.insert(container.bags, i) end
for i = NUM_BAG_SLOTS + 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do table.insert(container.bank, i) end
 
local frame = CreateFrame("FRAME")
frame:RegisterEvent("BANKFRAME_OPENED")
frame:SetScript("OnEvent", function(_, event)
if event == "BANKFRAME_OPENED" and AutoRestack then
kRestack("bank", true)
end
end)
 
local oToggleBackpack = ToggleBackpack
ToggleBackpack = function()
if AutoRestack and not InCombatLockdown() and (type(restacker) ~= "thread" or coroutine.status(restacker) == "dead") then
kRestack("bags", true)
end
return oToggleBackpack()
end
 
local function DecodeItemId(itemlink)
return select(3, strfind(itemlink, "item:(%d+)"))
end
42,9 → 27,9
if itemId == id then
local _, count, locked = GetContainerItemInfo(bag, slot)
local stack = select(8, GetItemInfo(itemId))
if stack > count then return true, bag, slot end
if count < stack then return true, bag, slot, count end
end
end
 
end
end
end
94,8 → 79,8
local locked, ok, pb, ps, pc
 
while true do
ok, pbag, pslot = RestackFindPartial(bag, slot, itemId, loc)
locked = ok and select(3, GetContainerItemInfo(pbag, pslot)) or false
ok, pb, ps, pc = RestackFindPartial(bag, slot, itemId, loc)
locked = ok and select(3, GetContainerItemInfo(pb, ps)) or false
 
if locked then
coroutine.yield()
106,9 → 91,10
 
if ok then
ClearCursor()
PickupContainerItem(pbag, pslot)
PickupContainerItem(pb, ps)
PickupContainerItem(bag, slot)
ClearCursor()
ClearCursor()
 
changed = true
end
end
118,34 → 104,35
return changed
end
 
local frame = CreateFrame("FRAME")
frame:RegisterEvent("BAG_UPDATE")
frame:SetScript("OnEvent", function()
if AutoRestack and type(restacker) ~= "thread" then
kRestack("bags", true)
end
end)
 
function kRestack(loc, nowarn)
if loc ~= "bags" and loc ~= "bank" then
local col = { w = "|cffFFFFFF", g = "|cff55FF55", r = "|cffFF5555" }
local krstr = "|cff44CCFFk|cffFFFFAARestack"..col.w
if loc == "auto" then
local togl
if not AutoRestack then
AutoRestack = true
togl = col.g.."ON"
if not AutoStack then
AutoStack = true
local tog = "|cff55FF55ON"
else
AutoRestack = false
togl = col.r.."OFF"
end
print(krstr, "Auto-stacking toggled", togl)
else
local status = AutoRestack and col.g.."on" or col.r.."off"
print(krstr, "Usage:")
print("- /restack [bags, bank]")
print("- /restack auto - toggles auto-stacking ("..status..col.w..")")
AutoStack = false
local tog = "|cffFF5555OFF"
end
print("|cff44CCFFk|cffFFFFAARestack |cffFFFFFFAuto-stacking toggled", tog)
else
print("|cff44CCFFk|cffFFFFAARestack")
print("- Usage: /restack [bags, bank]")
print("- /restack auto (toggles auto-stacking. default: off)")
end
 
do return end
end
 
if type(restacker) ~= "thread" or coroutine.status(restacker) == "dead" then
frame:SetScript("OnUpdate", function()
if type(restacker) == "thread" then coroutine.resume(restacker) end
end)
restacker = coroutine.create(function()
local changed = true
while changed == true do
158,7 → 145,7
for slot = 1, GetContainerNumSlots(bag) do
while true do
local locked = select( 3, GetContainerItemInfo(bag, slot))
 
 
if locked then
coroutine.yield()
else
169,11 → 156,11
local item = GetContainerItemLink(bag, slot)
 
if not item then
local locked, ok, sbag, sslot
local locked, ok, sb, ss
 
while true do
ok, sbag, sslot = RestackFindSpecial(bt, loc)
locked = ok and select(3, GetContainerItemInfo(sbag, sslot)) or false
ok, sb, ss = RestackFindSpecial(bt, loc)
locked = ok and select(3, GetContainerItemInfo(sb, ss)) or false
 
if locked then
coroutine.yield()
184,7 → 171,7
 
if ok then
ClearCursor()
PickupContainerItem(sbag, sslot)
PickupContainerItem(sb, ss)
PickupContainerItem(bag, slot)
ClearCursor()
end
194,9 → 181,12
end
frame:SetScript("OnUpdate", function() end)
end)
frame:SetScript("OnUpdate", function()
if type(restacker) == "thread" then coroutine.resume(restacker) end
end)
else
if not nowarn then
print("|cff33A1DEk|cffFFFFFFRestack |cffFF5555Restacking is already in progress, please wait.")
end
end
end
end
\ No newline at end of file
kRestack/kRestack.toc
1,8 → 1,8
## Interface: 30100
## Title: kRestack
## Version: 0.9.wowi:revision
## SavedVariablesPerCharacter: AutoRestack
## Author: Katae of Anvilmar
## Notes: Function for restacking inventory items.
## SavedVariablesPerCharacter: AutoRestack
 
kRestack.lua
\ No newline at end of file +kRestack.lua \ No newline at end of file