Skip to content

Commit

Permalink
store categories to not interfere between characters
Browse files Browse the repository at this point in the history
  • Loading branch information
DJSchaffner committed Feb 25, 2024
1 parent b9d9d1c commit 713d750
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions BetterBags_ItemRack.toc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Notes: Add a category to BetterBags for ItemRack sets
## Author: DJSchaffner
## Version: @1.3.0
## SavedVariables: CustomCategories
## Dependencies: BetterBags, ItemRack

main.lua
18 changes: 13 additions & 5 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ end
local function initCategories()
-- Prepare stored variable
if CustomCategories == nil then
printChat("Saved variable initialized..")
CustomCategories = {}
else
printChat("Saved variable restored..")
end

printChat("Initializing Categories..")
Expand All @@ -99,8 +102,13 @@ end

-------------------------------------------------------

-- Don't listen for load event since it should be loaded already (dependency)
ItemRack:RegisterExternalEventListener("ITEMRACK_SET_SAVED", itemRackUpdated)
ItemRack:RegisterExternalEventListener("ITEMRACK_SET_DELETED", itemRackUpdated)

initCategories()
frame:RegisterEvent("ADDON_LOADED")
frame:SetScript("OnEvent", function(self, event, addon, ...)
-- Listen for this because we need the saved variable to operate
if event == "ADDON_LOADED" and addon == "BetterBags_ItemRack" then
ItemRack:RegisterExternalEventListener("ITEMRACK_SET_SAVED", itemRackUpdated)
ItemRack:RegisterExternalEventListener("ITEMRACK_SET_DELETED", itemRackUpdated)

initCategories()
end
end)

0 comments on commit 713d750

Please sign in to comment.