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 |
|
--[[ initiate defaults ]] |
if type(AutoRestack) ~= "table" then |
AutoRestack = { } |
elseif AutoRestack.bags == nil then |
table.insert(AutoRestack.bags, true) |
elseif AutoRestack.bank == nil then |
table.insert(AutoRestack.bank, true) |
elseif AutoRestack.guild == nil then |
table.insert(AutoRestack.guild, false) |
end |
|
--[[ watching some events ]] |
local frame = CreateFrame("FRAME") |
local events = { "BANKFRAME_OPENED", "LOOT_OPENED", "TRADE_SHOW", "GUILDBANKFRAME_OPENED" } |
local events = { "ADDON_LOADED", "BANKFRAME_OPENED", "LOOT_OPENED", "TRADE_SHOW", "GUILDBANKFRAME_OPENED" } |
for _, r in pairs(events) do frame:RegisterEvent(r) end |
frame:SetScript("OnEvent", function(_, e) |
if AutoRestack.bank and e == events[1] then |
if e == events[1] then |
--[[ initialize saved variables ]] |
if type(AutoRestack) ~= "table" then AutoRestack = { } end |
if AutoRestack.bags == nil then AutoRestack.bags = true end |
if AutoRestack.bank == nil then AutoRestack.bank = true end |
if AutoRestack.guild == nil then AutoRestack.guild = false end |
elseif AutoRestack.bank and e == events[2] then |
kRestack("bank", true) |
elseif AutoRestack.bags and (e == events[2] or e == events[3]) then |
elseif AutoRestack.bags and (e == events[3] or e == events[4]) then |
kRestack("bags", true) |
elseif AutoRestack.guild and e == events[4] then |
elseif AutoRestack.guild and e == events[5] then |
kRestack("guild", true) |
end |
end) |