So I had saved variables working fine but then decided to change how they were stored in order to clean them up and make the code better… and broke them completely.
So I decided to create a second saved variable for “stats” and moved several variables out of the “settings” into it. Cut down versions of my ADDON_LOADED code here;
if event == "ADDON_LOADED" and arg1 == "CarnAddon" then
if CarnSettings == nil then
CarnSettings = {Theme = "Light", Scale = 1}
CarnStats = {Values = {[1]=0, [2]=0, [3]=0}, Names = {[1]="Bill", [2]="Ben", [3]="Carn"}}
end
MyTheme = CarnSettings.Theme
MyScale = CarnSettings.Scale
end
Where it’s been giving me grief is retrieving the stats. I’ve been getting errors whenever I try to retrieve the values or save them. I just stopped trying to assign them to my variables and didn’t touch them. That allowed the game to at least save the variables sucessfully. But they show up as the following (I cut the names section out for brevity):
CarnSettings = {
["Scale"] = 1,
["Theme"] = "Light",
}
CarnStats = {
["Values"] = {
0, -- [1]
0, -- [2]
0, -- [3]
},
}
The thinking was the “Values” entries are dynamic. There could be a bunch of them so it’d be better to reference them in the form (wrapped in loops obviously):
MyValues[i] = CarnStats.Values[i]
And similarly saving the values on logout would be something like
CarnStats.Values[i] = MyValues[i]
So what am I doing wrong? Is the syntax wrong? Should it be CarnStats.Values.i? (I thought I tried that unsuccessfully).