You've set up your data tables (sectionNames and mountList) as globals. They should really be included in your namespace table (core.sectionNames and core.mountList).
You could add the collection loaded check to MCL_Load:CreateMenu() before creating the frame and get rid of the whole init frame ADDON_LOADED stuff and just use the slash command
Lua Code:
local _, core = ...; -- Namespace
-------------------------------------------------------------
function core:Print(...)
local hex = select(4, self.Config:GetThemeColor());
local prefix = string.format("|cff%s%s|r", hex:upper(), "MCL:");
DEFAULT_CHAT_FRAME:AddMessage(string.join(" ", prefix, ...));
end
SLASH_MCL1 = "/mcl";
SlashCmdList.MCL = core.Config.Toggle;
Lua Code:
function MCL_Load:CreateMenu()
core:Print("Welcome back", UnitName("player").."!");
--Master Frame for addon
if not IsAddOnLoaded("Blizzard_Collections") then
LoadAddOn("Blizzard_Collections")
end
local MCL = CreateFrame("Frame", "MLCFrame", UIParent, "BasicFrameTemplateWithInset");
...
end
The "Welcome back" message is not really needed, they know they are playing and using your addon if they've gotten this far so...
You're also using a lot of globals with names like
totalCollected and
u and
total and
x and
y ... While it's easy for accessing data in various parts of your code, you really need to make sure that global names are absolutely unique to your addon
MCL_totalCollected,
MCL_u,
MCL_total etc. It may not be the cause of you problems but it will help stopping future possible problems.