-- -- Part of WoWLiCe Copyright (c)2008 Alex Quintana -- see main file for more copyright details -- -- LiCe Bags Module, formerly AlexBags -- Binding Variables BINDING_HEADER_WOWLICE = "LiCe"; BINDING_NAME_LBTOGGLE = "Toggle Bags 2-"; -- enables this addon to run standalone if (not LiCe) then LiCe = {}; end LiCe.Bags = {}; -- events that will force the backpack (and only the backpack) open local backpackEvents = { "PLAYER_ENTERING_WORLD", "MERCHANT_CLOSED", "MAIL_CLOSED", "BANKFRAME_CLOSED", "GUILDBANKFRAME_CLOSED", "TRADE_CLOSED" }; -- events that will force all bags open local otherBagEvents = { "MERCHANT_SHOW", "MAIL_SHOW", "BANKFRAME_OPENED", "GUILDBANKFRAME_OPENED", "TRADE_SHOW" }; -- OnLoad hook function LiCe.Bags:OnLoad() AlexLib:RegisterEvents(backpackEvents); AlexLib:RegisterEvents(otherBagEvents); end -- OnEvent hook function LiCe.Bags:OnEvent() --AlexLib:Print(event); -- check if this is an event that should open only the backpack -- this will also close the other bags on any event other than -- PLAYER_ENTERING_WORLD for k,v in pairs(backpackEvents) do if (event == v) then if (event ~= "PLAYER_ENTERING_WORLD") then AlexLib:CloseOtherBags(); if (event=="WORLD_MAP_UPDATE" and not IsBagOpen(BACKPACK_CONTAINER)) then OpenBackpack(); end end OpenBackpack(); return; end end -- check if this is an event that should open all bags, and do it for k,v in pairs(otherBagEvents) do if (event == v and not AlexLib:AllBagsOpen()) then LiCe.Bags:Toggle(); end end end -- Toggle other bags, keeping the Backpack open always function LiCe.Bags:Toggle() if (not IsBagOpen(BACKPACK_CONTAINER)) then OpenBackpack(); return; end local test; if (not AlexLib:AllBagsOpen() and HasKey()) then test = 1; end OpenAllBags(); OpenBackpack(); if (test) then ToggleKeyRing(); end end -- aeq/2k8