Added Bag content saving between game starts
This commit is contained in:
1 parent
0bcb17c54b
commit
1bd04bc72f
3 files changed
+13
-4
No files matched your search
+1
-1
@@ -739,7 +739,7 @@ end
|
|||||||
-- Result: "3{{Crafting3}}2{{Crafting2}}3{{Crafting1}}"
|
-- Result: "3{{Crafting3}}2{{Crafting2}}3{{Crafting1}}"
|
||||||
function EID:tableToCraftingIconsMerged(craftTable)
|
function EID:tableToCraftingIconsMerged(craftTable)
|
||||||
table.sort(craftTable, function(a, b) return a > b end)
|
table.sort(craftTable, function(a, b) return a > b end)
|
||||||
filteredList = {}
|
local filteredList = {}
|
||||||
for _,nr in ipairs(craftTable) do
|
for _,nr in ipairs(craftTable) do
|
||||||
if filteredList[nr] == nil then
|
if filteredList[nr] == nil then
|
||||||
filteredList[nr] = 1
|
filteredList[nr] = 1
|
||||||
|
|||||||
@@ -405,7 +405,7 @@ EID:AddCallback(ModCallbacks.MC_PRE_PICKUP_COLLISION, function(_, pickup,collide
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- Remove pickups picked up normally
|
-- Remove pickups picked up normally
|
||||||
pickupsOnInitCorrected = {}
|
local pickupsOnInitCorrected = {}
|
||||||
for _,e in ipairs (pickupsOnInit) do
|
for _,e in ipairs (pickupsOnInit) do
|
||||||
if GetPtrHash(pickup) ~= GetPtrHash(e) then
|
if GetPtrHash(pickup) ~= GetPtrHash(e) then
|
||||||
table.insert(pickupsOnInitCorrected, e)
|
table.insert(pickupsOnInitCorrected, e)
|
||||||
@@ -440,7 +440,6 @@ EID:AddCallback(ModCallbacks.MC_POST_ENTITY_REMOVE, function(_, bag)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end, EntityType.ENTITY_KNIFE)
|
end, EntityType.ENTITY_KNIFE)
|
||||||
|
|
||||||
local holdCounter = 0
|
local holdCounter = 0
|
||||||
@@ -494,6 +493,7 @@ function EID:handleBagOfCraftingRendering()
|
|||||||
for i, v in ipairs(floorItems) do
|
for i, v in ipairs(floorItems) do
|
||||||
table.insert(itemQuery, v)
|
table.insert(itemQuery, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, v in ipairs(EID.BagItems) do
|
for i, v in ipairs(EID.BagItems) do
|
||||||
table.insert(itemQuery, v)
|
table.insert(itemQuery, v)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -679,10 +679,16 @@ if EID.MCMLoaded or REPENTANCE then
|
|||||||
--------------------------------
|
--------------------------------
|
||||||
--------Handle Savadata---------
|
--------Handle Savadata---------
|
||||||
--------------------------------
|
--------------------------------
|
||||||
function OnGameStart(isSave)
|
function OnGameStart(_,isSave)
|
||||||
--Loading Moddata--
|
--Loading Moddata--
|
||||||
if EID:HasData() then
|
if EID:HasData() then
|
||||||
local savedEIDConfig = json.decode(Isaac.LoadModData(EID))
|
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
|
-- Only copy Saved config entries that exist in the save
|
||||||
if savedEIDConfig.Version == EID.Config.Version then
|
if savedEIDConfig.Version == EID.Config.Version then
|
||||||
local isDefaultConfig = true
|
local isDefaultConfig = true
|
||||||
@@ -708,6 +714,9 @@ if EID.MCMLoaded or REPENTANCE then
|
|||||||
|
|
||||||
--Saving Moddata--
|
--Saving Moddata--
|
||||||
function SaveGame()
|
function SaveGame()
|
||||||
|
if REPENTANCE then
|
||||||
|
EID.Config["BagContent"] = EID.BagItems or {}
|
||||||
|
end
|
||||||
EID.SaveData(EID, json.encode(EID.Config))
|
EID.SaveData(EID, json.encode(EID.Config))
|
||||||
end
|
end
|
||||||
EID:AddCallback(ModCallbacks.MC_PRE_GAME_EXIT, SaveGame)
|
EID:AddCallback(ModCallbacks.MC_PRE_GAME_EXIT, SaveGame)
|
||||||
|
|||||||
Reference in new issue
Block a user