fix: backfill missing learnedData settings keys from old SavedVariables

EnsureLearnedData was using 'or' which never updates an existing table.
If learnedData was created by an older version of the code without
learnQuests/learnItems/learnObjects keys, those stayed nil (falsy),
causing every quest/item/object learn call to return immediately.

Now explicitly backfills each missing key to true so all categories
record correctly regardless of when the SavedVariables were first created.
This commit is contained in:
Xurkon
2026-03-16 21:56:36 -05:00
parent 17bc28f440
commit b2ca8fa660
+29 -13
View File
@@ -78,19 +78,35 @@ end
local function EnsureLearnedData()
if not Questie.db then return false end
Questie.db.global.learnedData = Questie.db.global.learnedData or {
npcs = {},
quests = {},
items = {},
objects = {},
settings = {
enabled = true,
learnNpcs = true,
learnQuests = true,
learnItems = true,
learnObjects = true,
},
}
local ld = Questie.db.global.learnedData
if not ld then
Questie.db.global.learnedData = {
npcs = {},
quests = {},
items = {},
objects = {},
settings = {
enabled = true,
learnNpcs = true,
learnQuests = true,
learnItems = true,
learnObjects = true,
},
}
else
-- Backfill sub-tables that may be missing from older SavedVariables
ld.npcs = ld.npcs or {}
ld.quests = ld.quests or {}
ld.items = ld.items or {}
ld.objects = ld.objects or {}
ld.settings = ld.settings or {}
local s = ld.settings
if s.enabled == nil then s.enabled = true end
if s.learnNpcs == nil then s.learnNpcs = true end
if s.learnQuests == nil then s.learnQuests = true end
if s.learnItems == nil then s.learnItems = true end
if s.learnObjects == nil then s.learnObjects = true end
end
return true
end