I'm writting an addon that creates a savedvariable with a table of all addons and if they are enabled or disabled. The addon works, but I am not understanding the how the table structure is created. What I expexcted and what is written are two entirely different things. If someone could shed some light on this, it would be greatly appreciated. Following is the code involved and a snippet of the saved variable.
Lua Code:
## Interface: 70300
## Title: AddonList
## SavedVariables: AddonListDB
## DefaultState: disabled
AddonList.lua
Lua Code:
local addonlistdb
local JWFrame = CreateFrame("Frame");
function dostuff()
print("Do stuff")
--for i = 1,addcount do
--local name, title, notes, loadable, reason, security, newVersion = GetAddOnInfo(i)
--AddonListDB[i] = {title,IsAddonLoaded}
--print(title, IsAddOnLoaded(i))
--end
--print(#addlist..\" addons\")
--for k,v in ipairs(AddonListDB) do
--print(k,v[2],v[3])
--end
end
JWFrame:RegisterEvent("ADDON_LOADED");
JWFrame:SetScript("OnEvent", function(self, event, arg1)
if event == "ADDON_LOADED" and arg1 == "AddonList" then
addonlistdb = AddonListDB
-- Our saved variables, if they exist, have been loaded at this point.
if AddonListDB == nil then
print("No saved variables")
AddonListDB = {}
else
print("Saved variables exist")
local addcount = GetNumAddOns()
for i = 1,addcount do
local name, title, notes, loadable, reason, security, newVersion = GetAddOnInfo(i)
loaded, finished = IsAddOnLoaded(i)
AddonListDB[i] = {title,loaded}
--print(i,title,loaded)
end
end
end
print("Did stuff")
end)
SlashCmdList["ADDONLIST"] = function() dostuff() end
SLASH_ADDONLIST1 = "/al"
Ignore the comments, I am experimenting with code and a slash command.
Lua Code:
AddonListDB = {
{
"!!!Ease Addon Controller", -- [1]
false, -- [2]
}, -- [1]
{
"!!AceDB-DefaultMod", -- [1]
true, -- [2]
}, -- [2]
{
"_Cursor", -- [1]
false, -- [2]
}, -- [3]
395, -- [1]
"PictureThis", -- [2]
"|cffFF7700Picture|cff0055FFThis", -- [3]
}, -- [395]
{
396, -- [1]
"sFilter", -- [2]
"|cFFFFFFFFs|r|cFFFF8C00F|r|cFFFFFFFFilter Spells|r", -- [3]
}, -- [396]
What I was expecting in the saved variable is the addon name and if it is loaded/enabled. The first few entries confirm this, but some addons do not have true or false, it lists the title as seen by the last few entries. I am not sure why this is happening.
Also, where do the commented out numbers come from? The -- [1] etc...
Thanks and I hope everyone is enjoying the holidays no matter how you celebrate it.