I'm making an addon to easily provide roles for raid icons. I've made a config window inspirated by tekKonfig-AboutPanel which needs to show the text from the saved variables.
I'm using p3lim's code to copy the defaults into the SavedVariables if the values are nil:
Code:
local function LoadDefaults()
for k,v in next, defaults do
if(type(AssignDB[k]) == 'nil') then
AssignDB[k] = v
end
end
end
function Assign:OnInitialize()
LoadDefaults()
end
If this is the first time the addon is loaded I got an error the tells me that I'm trying to index global "AssignDB" in my LoadDefaults() function.
But if I just manually add a value in the SavedVariables like this
Code:
AssignDB = {
["dummy"] = 1,
}
The function copies the default table well and I got no error.
I just want to know if someone can tell me why I have a such error if my SavedVariables table is nil.
My two lua files are here if it can help:
Main Config