Saving fix

This commit is contained in:
theo@manjaro 2024-01-09 17:30:54 +01:00
parent 2da7f5202f
commit 790ba2471b
2 changed files with 10 additions and 9 deletions

View File

@ -15,11 +15,11 @@ mod.font = Font()
mod.font:Load("font/terminus.fnt") mod.font:Load("font/terminus.fnt")
function mod:isCurseBlind(pickupEntity) 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 return mod.game:GetLevel():GetCurses() & LevelCurse.CURSE_OF_BLIND > 0
end end
function mod.isIdNotTakenAlready(id) function mod.isIdNotTakenAlready(id, ignorerepentogon)
if id > 0 then if id > 0 then
-- Always returns seen if on a challenge -- Always returns seen if on a challenge
if Isaac.GetChallenge() ~= 0 then return false end if Isaac.GetChallenge() ~= 0 then return false end
@ -34,11 +34,9 @@ function mod.isIdNotTakenAlready(id)
end end
else else
-- Check using REPENTOGON -- Check using REPENTOGON
if isrepentogon then if isrepentogon and not ignorerepentogon then
if getgamedata():IsItemInCollection(id) then if getgamedata():IsItemInCollection(id) then
if not save.seen[id] then mod.registerTouched(id)
mod.registerTouched(id)
end
return false return false
end end
end end
@ -53,6 +51,7 @@ end
function mod.registerTouched(id) function mod.registerTouched(id)
-- Only register when not on a challenge -- Only register when not on a challenge
if Isaac.GetChallenge() == 0 then 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 >= 1 and id <= save.settings.maxid then save:touchid(id) end
if id >= save.settings.maxid then if id >= save.settings.maxid then
-- Modded item, save them by name -- Modded item, save them by name
@ -65,7 +64,10 @@ function mod.registerTouched(id)
end end
-- Save -- Save
mod:save() if shouldsave then -- Only save if there's a change
print("Saved "..id)
mod:save()
end
end end
end end

View File

@ -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. 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) 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. 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 :) Anyway, I hope that this mod will be useful to someone :)
Source code is available at https://forge.chapril.org/ayte/DeadGodHelper</description> Source code is available at https://forge.chapril.org/ayte/DeadGodHelper</description>
<version>1.12</version> <version>1.13</version>
<visibility>Public</visibility> <visibility>Public</visibility>
<tag id="Items"/> <tag id="Items"/>
<tag id="Tweaks"/> <tag id="Tweaks"/>