From 9d6b9f9c804b8da710b16edd224da6338ce621b4 Mon Sep 17 00:00:00 2001 From: "theo@manjaro" Date: Tue, 9 Jan 2024 17:57:54 +0100 Subject: [PATCH] Save fix --- main.lua | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/main.lua b/main.lua index e815f52..1ab05a3 100644 --- a/main.lua +++ b/main.lua @@ -19,7 +19,7 @@ function mod:isCurseBlind(pickupEntity) return mod.game:GetLevel():GetCurses() & LevelCurse.CURSE_OF_BLIND > 0 end -function mod.isIdNotTakenAlready(id, ignorerepentogon) +function mod.isIdNotTakenAlready(id) if id > 0 then -- Always returns seen if on a challenge if Isaac.GetChallenge() ~= 0 then return false end @@ -33,14 +33,6 @@ function mod.isIdNotTakenAlready(id, ignorerepentogon) end end else - -- Check using REPENTOGON - if isrepentogon and not ignorerepentogon then - if getgamedata():IsItemInCollection(id) then - mod.registerTouched(id) - return false - end - end - return not save.seen[id] end else @@ -51,7 +43,7 @@ end function mod.registerTouched(id) -- Only register when not on a challenge if Isaac.GetChallenge() == 0 then - local shouldsave = mod.isIdNotTakenAlready(id, true) + local shouldsave = mod.isIdNotTakenAlready(id) if id >= 1 and id <= save.settings.maxid then save:touchid(id) end if id >= save.settings.maxid then -- Modded item, save them by name @@ -64,10 +56,9 @@ function mod.registerTouched(id) end -- Save - if shouldsave then -- Only save if there's a change - print("Saved "..id) - mod:save() - end + if shouldsave then -- Only save if there's a change + mod:save() + end end end @@ -153,6 +144,14 @@ function mod:newrun() else save = savegen:new() end + -- Load info from repentogon if available + if isrepentogon then + for i = 1, save.settings.maxid do + if getgamedata():IsItemInCollection(i) then + mod.registerTouched(i) + end + end + end local c = 0 for _, v in ipairs(save.seen) do if v then c = c + 1 end end mod.print(modname .. " loaded, " .. c .. " vanilla items seen")