Added Bag content saving between game starts

This commit is contained in:
Wofsauge committed 2021-05-30 19:58:25 +02:00
1 parent 0bcb17c54b
commit 1bd04bc72f
3 files changed
+13 -4

No files matched your search

+1 -1
View File
@@ -739,7 +739,7 @@ end
-- Result: "3{{Crafting3}}2{{Crafting2}}3{{Crafting1}}"
function EID:tableToCraftingIconsMerged(craftTable)
table.sort(craftTable, function(a, b) return a > b end)
filteredList = {}
local filteredList = {}
for _,nr in ipairs(craftTable) do
if filteredList[nr] == nil then
filteredList[nr] = 1
+2 -2
View File
@@ -405,7 +405,7 @@ EID:AddCallback(ModCallbacks.MC_PRE_PICKUP_COLLISION, function(_, pickup,collide
return
end
-- Remove pickups picked up normally
pickupsOnInitCorrected = {}
local pickupsOnInitCorrected = {}
for _,e in ipairs (pickupsOnInit) do
if GetPtrHash(pickup) ~= GetPtrHash(e) then
table.insert(pickupsOnInitCorrected, e)
@@ -440,7 +440,6 @@ EID:AddCallback(ModCallbacks.MC_POST_ENTITY_REMOVE, function(_, bag)
end
end
end
end, EntityType.ENTITY_KNIFE)
local holdCounter = 0
@@ -494,6 +493,7 @@ function EID:handleBagOfCraftingRendering()
for i, v in ipairs(floorItems) do
table.insert(itemQuery, v)
end
for i, v in ipairs(EID.BagItems) do
table.insert(itemQuery, v)
end
+10 -1
View File
@@ -679,10 +679,16 @@ if EID.MCMLoaded or REPENTANCE then
--------------------------------
--------Handle Savadata---------
--------------------------------
function OnGameStart(isSave)
function OnGameStart(_,isSave)
--Loading Moddata--
if EID:HasData() then
local savedEIDConfig = json.decode(Isaac.LoadModData(EID))
if REPENTANCE and isSave then
EID.BagItems = savedEIDConfig["BagContent"]
savedEIDConfig["BagContent"] = nil
else
EID.BagItems = {}
end
-- Only copy Saved config entries that exist in the save
if savedEIDConfig.Version == EID.Config.Version then
local isDefaultConfig = true
@@ -708,6 +714,9 @@ if EID.MCMLoaded or REPENTANCE then
--Saving Moddata--
function SaveGame()
if REPENTANCE then
EID.Config["BagContent"] = EID.BagItems or {}
end
EID.SaveData(EID, json.encode(EID.Config))
end
EID:AddCallback(ModCallbacks.MC_PRE_GAME_EXIT, SaveGame)