diff --git a/BetterBags_ItemRack.toc b/BetterBags_ItemRack.toc index f56307a..9d2e7f8 100644 --- a/BetterBags_ItemRack.toc +++ b/BetterBags_ItemRack.toc @@ -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 diff --git a/main.lua b/main.lua index 9fcbcd2..d27b1db 100644 --- a/main.lua +++ b/main.lua @@ -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..") @@ -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() \ No newline at end of file +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)