From 790ba2471b86d4f7e9240c958ab4d3ed16246fbb Mon Sep 17 00:00:00 2001 From: "theo@manjaro" Date: Tue, 9 Jan 2024 17:30:54 +0100 Subject: [PATCH] Saving fix --- main.lua | 16 +++++++++------- metadata.xml | 3 +-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/main.lua b/main.lua index 743a6b4..e815f52 100644 --- a/main.lua +++ b/main.lua @@ -15,11 +15,11 @@ mod.font = Font() mod.font:Load("font/terminus.fnt") function mod:isCurseBlind(pickupEntity) - if isrepentogon then return pickupEntity:IsBlind() end + if isrepentogon then if pickupEntity:IsBlind() then return true end end return mod.game:GetLevel():GetCurses() & LevelCurse.CURSE_OF_BLIND > 0 end -function mod.isIdNotTakenAlready(id) +function mod.isIdNotTakenAlready(id, ignorerepentogon) if id > 0 then -- Always returns seen if on a challenge if Isaac.GetChallenge() ~= 0 then return false end @@ -34,11 +34,9 @@ function mod.isIdNotTakenAlready(id) end else -- Check using REPENTOGON - if isrepentogon then + if isrepentogon and not ignorerepentogon then if getgamedata():IsItemInCollection(id) then - if not save.seen[id] then - mod.registerTouched(id) - end + mod.registerTouched(id) return false end end @@ -53,6 +51,7 @@ end function mod.registerTouched(id) -- Only register when not on a challenge if Isaac.GetChallenge() == 0 then + local shouldsave = mod.isIdNotTakenAlready(id, true) 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 @@ -65,7 +64,10 @@ function mod.registerTouched(id) end -- Save - mod:save() + if shouldsave then -- Only save if there's a change + print("Saved "..id) + mod:save() + end end end diff --git a/metadata.xml b/metadata.xml index cbf9106..7524289 100644 --- a/metadata.xml +++ b/metadata.xml @@ -11,7 +11,6 @@ Now supports modded items, and integration with Repentogon! I made it mainly for myself, because it was annoying to go back to the menu every time I encountered an item I was unsure about. -There's an integration with External Item Description. It is also compatible with Mod Config Menu, if you want to toggle things (such as displaying info when on Curse Of The Blind) Mods can't access the savefile directly, so the mod tracks itself witch items are taken. This means that the first time you install it, everything will be marked as new. @@ -24,7 +23,7 @@ This mod is still relevant in itself if you do not want to use external tools, o Anyway, I hope that this mod will be useful to someone :) Source code is available at https://forge.chapril.org/ayte/DeadGodHelper - 1.12 + 1.13 Public