Hopefully no more save deletion
This commit is contained in:
parent
829576b696
commit
258ea85277
13
main.lua
13
main.lua
@ -6,6 +6,7 @@ mod.print = Isaac.ConsoleOutput
|
||||
mod.game = Game()
|
||||
local savegen = include("save")
|
||||
local save = savegen:new()
|
||||
local saveloaded = false
|
||||
local json = include("json")
|
||||
local DEBUG = false
|
||||
local getgamedata = Isaac.GetPersistentGameData -- Repentogon exclusive
|
||||
@ -141,6 +142,7 @@ function mod:newrun()
|
||||
if DEBUG then mod.print(data .. "\n") end
|
||||
save = savegen:new()
|
||||
save:load(json, data)
|
||||
saveloaded = true
|
||||
else
|
||||
save = savegen:new()
|
||||
end
|
||||
@ -163,19 +165,26 @@ function mod:newrun()
|
||||
mod.print(".\n")
|
||||
end
|
||||
|
||||
function mod:endrun()
|
||||
saveloaded = false
|
||||
end
|
||||
|
||||
function mod:save() mod:SaveData(save:dump(json)) end
|
||||
|
||||
mod:AddCallback(ModCallbacks.MC_POST_GAME_END, mod.save)
|
||||
mod:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, mod.newrun)
|
||||
mod:AddCallback(ModCallbacks.MC_PRE_GAME_EXIT, mod.endrun)
|
||||
|
||||
if not isrepentogon then
|
||||
-- Used to check for new items
|
||||
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, mod.update)
|
||||
else
|
||||
function mod.addCollectibleCallaback(_, id, _, _, _, _)
|
||||
mod.registerTouched(id)
|
||||
if saveloaded then
|
||||
mod.registerTouched(id)
|
||||
end
|
||||
end
|
||||
-- This is not a vanilla callback, it is from repentogon
|
||||
-- This is not a vanilla callback
|
||||
mod:AddCallback(ModCallbacks.MC_POST_ADD_COLLECTIBLE,
|
||||
mod.addCollectibleCallaback)
|
||||
end
|
||||
|
@ -23,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</description>
|
||||
<version>1.13</version>
|
||||
<version>1.14</version>
|
||||
<visibility>Public</visibility>
|
||||
<tag id="Items"/>
|
||||
<tag id="Tweaks"/>
|
||||
|
Loading…
Reference in New Issue
Block a user