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