Compare commits
No commits in common. "2d46b7ad6ccf7fbc4ae5c19f2edf9b3081192adb" and "445048531dfde2545da5e60187391df1cc1f943b" have entirely different histories.
2d46b7ad6c
...
445048531d
91
main.lua
91
main.lua
@ -3,9 +3,7 @@ local mod = RegisterMod(modname, 1)
|
||||
local math = require("math")
|
||||
mod.print = Isaac.ConsoleOutput
|
||||
mod.game = Game()
|
||||
local savegen = include("save")
|
||||
local save = savegen:new()
|
||||
local json = include("json")
|
||||
local save = include("save"):new()
|
||||
local DEBUG = false
|
||||
|
||||
mod.font = Font()
|
||||
@ -18,34 +16,19 @@ end
|
||||
function mod.isIdNotTakenAlready(id)
|
||||
if id>=1 and id<=save.settings.maxid then
|
||||
return not save.seen[id]
|
||||
else
|
||||
return false
|
||||
end
|
||||
if id>save.settings.maxid and save.settings.showonmodded then
|
||||
local itemconfig = Isaac.GetItemConfig():GetCollectible(id)
|
||||
if itemconfig then
|
||||
local name = itemconfig.Name
|
||||
return not save.seenmodded[name]
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function mod.registerTouched(id)
|
||||
if id>=1 and id<=save.settings.maxid then
|
||||
save:touchid(id)
|
||||
end
|
||||
if id >=save.settings.maxid then
|
||||
-- Modded item, save them by name
|
||||
-- (as IDs are choosen manually by the game, and may vary when changing mods)
|
||||
local itemconfig = Isaac.GetItemConfig():GetCollectible(id)
|
||||
if itemconfig then
|
||||
local name = itemconfig.Name
|
||||
save:touchname(name)
|
||||
end
|
||||
save.seen[id] = true
|
||||
end
|
||||
|
||||
-- Save
|
||||
mod:save()
|
||||
mod:RemoveData()
|
||||
mod:SaveData(save:dump())
|
||||
end
|
||||
|
||||
-- Used to check if EID's description should be modified
|
||||
@ -63,11 +46,7 @@ end
|
||||
-- Used to modify EID's description
|
||||
function mod.modifierCallback(descObj)
|
||||
if save.settings.eid then
|
||||
local str = "#{{Collectible}} Not picked up yet!#"
|
||||
if descObj.ObjSubType>save.settings.maxid then
|
||||
str = "#{{Trinket}} Not picked up yet!#"
|
||||
end
|
||||
descObj.Description = str..descObj.Description
|
||||
descObj.Description = "#{{Trophy}} Not picked up yet!#"..descObj.Description
|
||||
end
|
||||
return descObj
|
||||
end
|
||||
@ -103,12 +82,7 @@ function mod:PickupDrawCallback(pickupEntity, _)
|
||||
if pickupEntity.Variant==PickupVariant.PICKUP_COLLECTIBLE then
|
||||
if mod.isIdNotTakenAlready(pickupEntity.SubType) then
|
||||
local v = Isaac.WorldToScreen(pickupEntity.Position + pickupEntity.SpriteOffset)
|
||||
local color = KColor(0.98,0.93,0.55,1)
|
||||
if pickupEntity.SubType > save.settings.maxid then
|
||||
-- Modded item
|
||||
color = KColor(0.68,0.88,1,1)
|
||||
end
|
||||
mod.font:DrawString("!", v.X-1, v.Y-52+math.sin(mod.game:GetFrameCount()/10)*2, color , 2, true)
|
||||
mod.font:DrawString("!", v.X-1, v.Y-52+math.sin(mod.game:GetFrameCount()/10)*2, KColor(0.98,0.93,0.55,1), 2, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -120,31 +94,20 @@ function mod:newrun()
|
||||
if DEBUG then
|
||||
mod.print(data.."\n")
|
||||
end
|
||||
save = savegen:new()
|
||||
save:load(json, data)
|
||||
save:load(data)
|
||||
local c = 0
|
||||
for _,v in ipairs(save.seen) do
|
||||
if v then c = c+1 end
|
||||
end
|
||||
mod.print(modname.." loaded, "..c.." vanilla items seen")
|
||||
if save.settings.showonmodded then
|
||||
local c = 0
|
||||
for _,v in pairs(save.seenmodded) do
|
||||
if v then
|
||||
c = c + 1
|
||||
end
|
||||
end
|
||||
mod.print(", "..tostring(c).." modded")
|
||||
end
|
||||
mod.print(".\n")
|
||||
mod.print(modname.." Loaded, "..c.." items seen\n")
|
||||
end
|
||||
end
|
||||
|
||||
function mod:save()
|
||||
mod:SaveData(save:dump(json))
|
||||
function mod:preGameExit()
|
||||
mod:SaveData(save:dump())
|
||||
end
|
||||
|
||||
mod:AddCallback(ModCallbacks.MC_POST_GAME_END, mod.save)
|
||||
mod:AddCallback(ModCallbacks.MC_POST_GAME_END, mod.preGameExit)
|
||||
mod:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, mod.newrun)
|
||||
|
||||
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, mod.update)
|
||||
@ -172,7 +135,7 @@ if ModConfigMenu then
|
||||
end,
|
||||
OnChange = function(b)
|
||||
save.settings.eid = b
|
||||
mod:save()
|
||||
mod:SaveData(save:dump())
|
||||
end,
|
||||
}
|
||||
)
|
||||
@ -189,29 +152,7 @@ if ModConfigMenu then
|
||||
end,
|
||||
OnChange = function(b)
|
||||
save.settings.visual = b
|
||||
mod:save()
|
||||
end,
|
||||
}
|
||||
)
|
||||
|
||||
ModConfigMenu.AddSetting(
|
||||
modname, -- This should be unique for your mod
|
||||
nil,
|
||||
{
|
||||
Type = ModConfigMenu.OptionType.BOOLEAN,
|
||||
CurrentSetting = function()
|
||||
return save.settings.showonmodded
|
||||
end,
|
||||
Display = function()
|
||||
return "Also track modded items: " .. (save.settings.showonmodded and "on" or "off")
|
||||
end,
|
||||
OnChange = function(b)
|
||||
save.settings.showonmodded = b
|
||||
if b==false then
|
||||
-- Reset modded items
|
||||
save.seenmodded = {}
|
||||
end
|
||||
mod:save()
|
||||
mod:SaveData(save:dump())
|
||||
end,
|
||||
}
|
||||
)
|
||||
@ -229,7 +170,7 @@ if ModConfigMenu then
|
||||
end,
|
||||
OnChange = function(b)
|
||||
save.settings.showonblind = b
|
||||
mod:save()
|
||||
mod:SaveData(save:dump())
|
||||
end,
|
||||
}
|
||||
)
|
||||
|
@ -12,15 +12,12 @@ I made it mainly for myself, because it was annoying to go back to the menu ever
|
||||
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)
|
||||
|
||||
[strike]There's however a limitation: since (to my knowledge) there's no way to get information about seen items from the savefile, this mod takes it upon itself to track which item you picked up. (This means that when you install the mod for the first time, every item will be tagged as unseen)[/strike]
|
||||
|
||||
EDIT: Turns out EID already has a support for this, using a save extractor, if you want to go down that route, here's the link to the extractor : https://github.com/wofsauge/External-Item-Descriptions/tree/master/scripts
|
||||
This mod is still somewhat relevant if you do not want to use external tools ^^
|
||||
There's however a limitation: since (to my knowledge) there's no way to get information about seen items from the savefile, this mod takes it upon itself to track which item you picked up. (This means that when you install the mod for the first time, every item will be tagged as unseen)
|
||||
|
||||
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.9</version>
|
||||
<version>1.7</version>
|
||||
<visibility>Public</visibility>
|
||||
<tag id="Items"/>
|
||||
<tag id="Graphics"/>
|
||||
|
83
save.lua
83
save.lua
@ -7,7 +7,6 @@ function savegen:new()
|
||||
save.settings = {}
|
||||
save.settings.eid = true
|
||||
save.settings.visual = true
|
||||
save.settings.showonmodded = true
|
||||
save.settings.showonblind = false
|
||||
save.settings.maxid = 732
|
||||
|
||||
@ -16,82 +15,22 @@ function savegen:new()
|
||||
save.seen[i] = false
|
||||
end
|
||||
|
||||
save.seenmodded = {}
|
||||
|
||||
function save:touchid(id)
|
||||
-- Non-modded
|
||||
function save:touch(id)
|
||||
self.seen[id] = true
|
||||
end
|
||||
|
||||
function save:touchname(name)
|
||||
-- Modded, save by name
|
||||
self.seenmodded[name] = true
|
||||
function save:dump()
|
||||
-- Returns a string representation of the save
|
||||
-- Bool to symbol
|
||||
local f = function(x) return (x and "1") or "0" end
|
||||
local result = f(self.settings.eid)..f(self.settings.visual)..f(self.settings.showonblind)
|
||||
for i=1, save.settings.maxid do
|
||||
result = result..f(save.seen[i])
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
function save:dump(json)
|
||||
local data = {}
|
||||
if self.settings then
|
||||
data.settings = {}
|
||||
data.settings.eid = self.settings.eid
|
||||
data.settings.visual = self.settings.visual
|
||||
data.settings.showonblind = self.settings.showonblind
|
||||
data.settings.showonmodded = self.settings.showonmodded
|
||||
end
|
||||
if self.seen then
|
||||
data.seen = {}
|
||||
for i=1, #save.seen do
|
||||
data.seen[i] = self.seen[i]
|
||||
end
|
||||
end
|
||||
if self.seenmodded then
|
||||
data.seenmodded = {}
|
||||
for i,v in pairs(self.seenmodded) do
|
||||
data.seenmodded[i] = v
|
||||
end
|
||||
end
|
||||
|
||||
return json.encode(data)
|
||||
end
|
||||
|
||||
function save:load(json, text)
|
||||
if save:islegacysave(text) then
|
||||
save:legacyload(text)
|
||||
return save
|
||||
else
|
||||
local data = json.decode(text)
|
||||
if data.settings then
|
||||
save.settings.eid = data.settings.eid
|
||||
save.settings.visual = data.settings.visual
|
||||
save.settings.showonblind = data.settings.showonblind
|
||||
save.settings.showonmodded = data.settings.showonmodded
|
||||
end
|
||||
if data.seen then
|
||||
for i=1, #data.seen do
|
||||
save.seen[i] = data.seen[i]
|
||||
end
|
||||
end
|
||||
if data.seenmodded then
|
||||
for i,v in pairs(data.seenmodded) do
|
||||
save.seenmodded[i] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function save:islegacysave(text)
|
||||
-- Check if legacy (before modded items support) save
|
||||
for i=1, math.min(#text,self.settings.maxid+3) do
|
||||
local digit = string.sub(text,i,i)
|
||||
if digit~="0" and digit~="1" then
|
||||
-- Not a legacy save
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function save:legacyload(text)
|
||||
-- Pre modded items support
|
||||
function save:load(text)
|
||||
-- Change attributes based on the text
|
||||
-- Symbol to bool
|
||||
local f = function(x, i)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 182 KiB |
Binary file not shown.
Before Width: | Height: | Size: 176 KiB |
Loading…
Reference in New Issue
Block a user