Getting data from repentogon
This commit is contained in:
parent
f78740be7d
commit
eeba233fc8
363
main.lua
363
main.lua
@ -1,3 +1,4 @@
|
|||||||
|
-- Formatted using lua-format
|
||||||
local modname = "DeadGod Helper"
|
local modname = "DeadGod Helper"
|
||||||
local mod = RegisterMod(modname, 1)
|
local mod = RegisterMod(modname, 1)
|
||||||
local math = require("math")
|
local math = require("math")
|
||||||
@ -7,150 +8,160 @@ local savegen = include("save")
|
|||||||
local save = savegen:new()
|
local save = savegen:new()
|
||||||
local json = include("json")
|
local json = include("json")
|
||||||
local DEBUG = false
|
local DEBUG = false
|
||||||
|
local getgamedata = Isaac.GetPersistentGameData -- Repentogon exclusive
|
||||||
|
|
||||||
mod.font = Font()
|
mod.font = Font()
|
||||||
mod.font:Load("font/terminus.fnt")
|
mod.font:Load("font/terminus.fnt")
|
||||||
|
|
||||||
function mod:isCurseBlind()
|
function mod:isCurseBlind()
|
||||||
return mod.game:GetLevel():GetCurses() & LevelCurse.CURSE_OF_BLIND > 0
|
return mod.game:GetLevel():GetCurses() & LevelCurse.CURSE_OF_BLIND > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function mod.isIdNotTakenAlready(id)
|
function mod.isIdNotTakenAlready(id)
|
||||||
-- Always returns seen if on a challenge
|
if id > 0 then
|
||||||
if Isaac.GetChallenge()~=0 then return false end
|
-- Always returns seen if on a challenge
|
||||||
|
if Isaac.GetChallenge() ~= 0 then return false end
|
||||||
|
|
||||||
if id>=1 and id<=save.settings.maxid then
|
-- Check using REPENTOGON
|
||||||
return not save.seen[id]
|
if getgamedata then
|
||||||
end
|
if getgamedata():IsItemInCollection(id) then
|
||||||
if id>save.settings.maxid and save.settings.showonmodded then
|
if not save.seen[id] then
|
||||||
local itemconfig = Isaac.GetItemConfig():GetCollectible(id)
|
save:touchid(id)
|
||||||
if itemconfig then
|
mod:save()
|
||||||
local name = itemconfig.Name
|
end
|
||||||
return not save.seenmodded[name]
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
if id <= save.settings.maxid then return not save.seen[id] 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
|
||||||
|
else
|
||||||
|
return false -- Don't show on empty pedestals
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mod.registerTouched(id)
|
function mod.registerTouched(id)
|
||||||
-- Only register when not on a challenge
|
-- Only register when not on a challenge
|
||||||
if Isaac.GetChallenge()==0 then
|
if Isaac.GetChallenge() == 0 then
|
||||||
if id>=1 and id<=save.settings.maxid then
|
if id >= 1 and id <= save.settings.maxid then save:touchid(id) end
|
||||||
save:touchid(id)
|
if id >= save.settings.maxid then
|
||||||
end
|
-- Modded item, save them by name
|
||||||
if id >=save.settings.maxid then
|
-- (as IDs are choosen manually by the game, and may vary when changing mods)
|
||||||
-- Modded item, save them by name
|
local itemconfig = Isaac.GetItemConfig():GetCollectible(id)
|
||||||
-- (as IDs are choosen manually by the game, and may vary when changing mods)
|
if itemconfig then
|
||||||
local itemconfig = Isaac.GetItemConfig():GetCollectible(id)
|
local name = itemconfig.Name
|
||||||
if itemconfig then
|
save:touchname(name)
|
||||||
local name = itemconfig.Name
|
end
|
||||||
save:touchname(name)
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Save
|
-- Save
|
||||||
mod:save()
|
mod:save()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Used to check if EID's description should be modified
|
-- Used to check if EID's description should be modified
|
||||||
function mod.shouldBeModified(descObj)
|
function mod.shouldBeModified(descObj)
|
||||||
-- Taken from https://github.com/wofsauge/External-Item-Descriptions/wiki/Description-Modifiers
|
-- Taken from https://github.com/wofsauge/External-Item-Descriptions/wiki/Description-Modifiers
|
||||||
-- if entity is a piedestal
|
-- if entity is a piedestal
|
||||||
if descObj.ObjType == 5 and descObj.ObjVariant == 100 then
|
if descObj.ObjType == 5 and descObj.ObjVariant == 100 then
|
||||||
-- Check if item was not already taken in this savefile
|
-- Check if item was not already taken in this savefile
|
||||||
-- And if item is non-modded (id<= Mom's ring ID)
|
-- And if item is non-modded (id<= Mom's ring ID)
|
||||||
local id = descObj.ObjSubType
|
local id = descObj.ObjSubType
|
||||||
return mod.isIdNotTakenAlready(id)
|
return mod.isIdNotTakenAlready(id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Used to modify EID's description
|
-- Used to modify EID's description
|
||||||
function mod.modifierCallback(descObj)
|
function mod.modifierCallback(descObj)
|
||||||
if save.settings.eid then
|
if save.settings.eid then
|
||||||
local str = "#{{Collectible}} Not picked up yet!#"
|
local str = "#{{Collectible}} Not picked up yet!#"
|
||||||
if descObj.ObjSubType>save.settings.maxid then
|
if descObj.ObjSubType > save.settings.maxid then
|
||||||
str = "#{{Trinket}} Not picked up yet!#"
|
str = "#{{Trinket}} Not picked up yet!#"
|
||||||
end
|
end
|
||||||
descObj.Description = str..descObj.Description
|
descObj.Description = str .. descObj.Description
|
||||||
end
|
end
|
||||||
return descObj
|
return descObj
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Used to detect when an item is picked up
|
-- Used to detect when an item is picked up
|
||||||
function mod:update()
|
function mod:update()
|
||||||
for i=0, mod.game:GetNumPlayers()-1 do
|
for i = 0, mod.game:GetNumPlayers() - 1 do
|
||||||
local player = mod.game:GetPlayer(i)
|
local player = mod.game:GetPlayer(i)
|
||||||
local data = player:GetData()
|
local data = player:GetData()
|
||||||
local item = player.QueuedItem.Item
|
local item = player.QueuedItem.Item
|
||||||
if data._deadgodlastid and data._deadgodlastcount and data._deadgodlastid>0 then
|
if data._deadgodlastid and data._deadgodlastcount and
|
||||||
if item==nil then -- Finished animation
|
data._deadgodlastid > 0 then
|
||||||
if player:GetCollectibleNum(data._deadgodlastid)>data._deadgodlastcount then -- Have it on me
|
if item == nil then -- Finished animation
|
||||||
-- Then I just picked it up, yay
|
if player:GetCollectibleNum(data._deadgodlastid) >
|
||||||
mod.registerTouched(data._deadgodlastid)
|
data._deadgodlastcount then -- Have it on me
|
||||||
if DEBUG then
|
-- Then I just picked it up, yay
|
||||||
mod.print("> "..tostring(data._deadgodlastid).."\n")
|
mod.registerTouched(data._deadgodlastid)
|
||||||
end
|
if DEBUG then
|
||||||
data._deadgodlastid = 0
|
mod.print("> " .. tostring(data._deadgodlastid) .. "\n")
|
||||||
data._deadgodlastcount = 0
|
end
|
||||||
end end
|
data._deadgodlastid = 0
|
||||||
end
|
data._deadgodlastcount = 0
|
||||||
if item and item:IsCollectible() then
|
end
|
||||||
data._deadgodlastid = item.ID
|
end
|
||||||
data._deadgodlastcount = player:GetCollectibleNum(item.ID)
|
end
|
||||||
end
|
if item and item:IsCollectible() then
|
||||||
end
|
data._deadgodlastid = item.ID
|
||||||
|
data._deadgodlastcount = player:GetCollectibleNum(item.ID)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Used to draw the ! sign
|
-- Used to draw the ! sign
|
||||||
function mod:PickupDrawCallback(pickupEntity, _)
|
function mod:PickupDrawCallback(pickupEntity, _)
|
||||||
if save.settings.visual and (not mod:isCurseBlind() or save.settings.showonblind)then
|
if save.settings.visual and
|
||||||
if pickupEntity.Variant==PickupVariant.PICKUP_COLLECTIBLE then
|
(not mod:isCurseBlind() or save.settings.showonblind) then
|
||||||
if mod.isIdNotTakenAlready(pickupEntity.SubType) then
|
if pickupEntity.Variant == PickupVariant.PICKUP_COLLECTIBLE then
|
||||||
local v = Isaac.WorldToScreen(pickupEntity.Position + pickupEntity.SpriteOffset)
|
if mod.isIdNotTakenAlready(pickupEntity.SubType) then
|
||||||
local color = KColor(0.98,0.93,0.55,1)
|
local v = Isaac.WorldToScreen(
|
||||||
if pickupEntity.SubType > save.settings.maxid then
|
pickupEntity.Position + pickupEntity.SpriteOffset)
|
||||||
-- Modded item
|
local color = KColor(0.98, 0.93, 0.55, 1)
|
||||||
color = KColor(0.68,0.88,1,1)
|
if pickupEntity.SubType > save.settings.maxid then
|
||||||
end
|
-- Modded item
|
||||||
mod.font:DrawString("!", v.X-1, v.Y-52+math.sin(mod.game:GetFrameCount()/10)*2, color , 2, true)
|
color = KColor(0.68, 0.88, 1, 1)
|
||||||
end
|
end
|
||||||
end
|
mod.font:DrawString("!", v.X - 1, v.Y - 52 +
|
||||||
end
|
math.sin(mod.game:GetFrameCount() / 10) *
|
||||||
|
2, color, 2, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mod:newrun()
|
function mod:newrun()
|
||||||
if mod:HasData() then
|
if mod:HasData() then
|
||||||
local data = mod:LoadData()
|
local data = mod:LoadData()
|
||||||
if DEBUG then
|
if DEBUG then mod.print(data .. "\n") end
|
||||||
mod.print(data.."\n")
|
save = savegen:new()
|
||||||
end
|
save:load(json, data)
|
||||||
save = savegen:new()
|
else
|
||||||
save:load(json, data)
|
save = savegen:new()
|
||||||
else
|
end
|
||||||
save = savegen:new()
|
local c = 0
|
||||||
end
|
for _, v in ipairs(save.seen) do if v then c = c + 1 end end
|
||||||
local c = 0
|
mod.print(modname .. " loaded, " .. c .. " vanilla items seen")
|
||||||
for _,v in ipairs(save.seen) do
|
if save.settings.showonmodded then
|
||||||
if v then c = c+1 end
|
local c = 0
|
||||||
end
|
for _, v in pairs(save.seenmodded) do if v then c = c + 1 end end
|
||||||
mod.print(modname.." loaded, "..c.." vanilla items seen")
|
mod.print(", " .. tostring(c) .. " modded")
|
||||||
if save.settings.showonmodded then
|
end
|
||||||
local c = 0
|
mod.print(".\n")
|
||||||
for _,v in pairs(save.seenmodded) do
|
|
||||||
if v then
|
|
||||||
c = c + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mod.print(", "..tostring(c).." modded")
|
|
||||||
end
|
|
||||||
mod.print(".\n")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function mod:save()
|
function mod:save() mod:SaveData(save:dump(json)) end
|
||||||
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)
|
||||||
@ -159,86 +170,66 @@ mod:AddCallback(ModCallbacks.MC_POST_UPDATE, mod.update)
|
|||||||
mod:AddCallback(ModCallbacks.MC_POST_PICKUP_RENDER, mod.PickupDrawCallback)
|
mod:AddCallback(ModCallbacks.MC_POST_PICKUP_RENDER, mod.PickupDrawCallback)
|
||||||
|
|
||||||
if EID then
|
if EID then
|
||||||
EID:addDescriptionModifier(
|
EID:addDescriptionModifier(modname, mod.shouldBeModified,
|
||||||
modname,
|
mod.modifierCallback)
|
||||||
mod.shouldBeModified,
|
|
||||||
mod.modifierCallback
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if ModConfigMenu then
|
if ModConfigMenu then
|
||||||
ModConfigMenu.AddSetting(
|
ModConfigMenu.AddSetting(modname, -- This should be unique for your mod
|
||||||
modname, -- This should be unique for your mod
|
nil, {
|
||||||
nil,
|
Type = ModConfigMenu.OptionType.BOOLEAN,
|
||||||
{
|
CurrentSetting = function() return save.settings.eid end,
|
||||||
Type = ModConfigMenu.OptionType.BOOLEAN,
|
Display = function()
|
||||||
CurrentSetting = function()
|
return "Show in EID: " .. (save.settings.eid and "on" or "off")
|
||||||
return save.settings.eid
|
end,
|
||||||
end,
|
OnChange = function(b)
|
||||||
Display = function()
|
save.settings.eid = b
|
||||||
return "Show in EID: " .. (save.settings.eid and "on" or "off")
|
mod:save()
|
||||||
end,
|
end
|
||||||
OnChange = function(b)
|
})
|
||||||
save.settings.eid = b
|
ModConfigMenu.AddSetting(modname, -- This should be unique for your mod
|
||||||
mod:save()
|
nil, {
|
||||||
end,
|
Type = ModConfigMenu.OptionType.BOOLEAN,
|
||||||
}
|
CurrentSetting = function() return save.settings.visual end,
|
||||||
)
|
Display = function()
|
||||||
ModConfigMenu.AddSetting(
|
return "Show on pedestals: " ..
|
||||||
modname, -- This should be unique for your mod
|
(save.settings.visual and "on" or "off")
|
||||||
nil,
|
end,
|
||||||
{
|
OnChange = function(b)
|
||||||
Type = ModConfigMenu.OptionType.BOOLEAN,
|
save.settings.visual = b
|
||||||
CurrentSetting = function()
|
mod:save()
|
||||||
return save.settings.visual
|
end
|
||||||
end,
|
})
|
||||||
Display = function()
|
|
||||||
return "Show on pedestals: " .. (save.settings.visual and "on" or "off")
|
|
||||||
end,
|
|
||||||
OnChange = function(b)
|
|
||||||
save.settings.visual = b
|
|
||||||
mod:save()
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
ModConfigMenu.AddSetting(
|
ModConfigMenu.AddSetting(modname, -- This should be unique for your mod
|
||||||
modname, -- This should be unique for your mod
|
nil, {
|
||||||
nil,
|
Type = ModConfigMenu.OptionType.BOOLEAN,
|
||||||
{
|
CurrentSetting = function() return save.settings.showonmodded end,
|
||||||
Type = ModConfigMenu.OptionType.BOOLEAN,
|
Display = function()
|
||||||
CurrentSetting = function()
|
return "Also track modded items: " ..
|
||||||
return save.settings.showonmodded
|
(save.settings.showonmodded and "on" or "off")
|
||||||
end,
|
end,
|
||||||
Display = function()
|
OnChange = function(b)
|
||||||
return "Also track modded items: " .. (save.settings.showonmodded and "on" or "off")
|
save.settings.showonmodded = b
|
||||||
end,
|
if b == false then
|
||||||
OnChange = function(b)
|
-- Reset modded items
|
||||||
save.settings.showonmodded = b
|
save.seenmodded = {}
|
||||||
if b==false then
|
end
|
||||||
-- Reset modded items
|
mod:save()
|
||||||
save.seenmodded = {}
|
end
|
||||||
end
|
})
|
||||||
mod:save()
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
ModConfigMenu.AddSetting(
|
ModConfigMenu.AddSetting(modname, -- This should be unique for your mod
|
||||||
modname, -- This should be unique for your mod
|
nil, {
|
||||||
nil,
|
Type = ModConfigMenu.OptionType.BOOLEAN,
|
||||||
{
|
CurrentSetting = function() return save.settings.showonblind end,
|
||||||
Type = ModConfigMenu.OptionType.BOOLEAN,
|
Display = function()
|
||||||
CurrentSetting = function()
|
return "Show while having Curse Of The Blind: " ..
|
||||||
return save.settings.showonblind
|
(save.settings.showonblind and "on" or "off")
|
||||||
end,
|
end,
|
||||||
Display = function()
|
OnChange = function(b)
|
||||||
return "Show while having Curse Of The Blind: " .. (save.settings.showonblind and "on" or "off")
|
save.settings.showonblind = b
|
||||||
end,
|
mod:save()
|
||||||
OnChange = function(b)
|
end
|
||||||
save.settings.showonblind = b
|
})
|
||||||
mod:save()
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<name>DeadGod Helper</name>
|
<name>DeadGod Helper</name>
|
||||||
<directory>deadgod helper</directory>
|
<directory>deadgod helper</directory>
|
||||||
<id>2985754961</id>
|
<id>2985754961</id>
|
||||||
<description>Spot missing items!
|
<description>Spot missing items!
|
||||||
|
|
||||||
Easily spot items that were not previously picked up on this savefile. Very useful when you're trying to get a second or third Dead God.
|
Easily spot items that were not previously picked up on this savefile. Very useful when you're trying to get a second or third Dead God.
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ It is also compatible with Mod Config Menu, if you want to toggle things (such a
|
|||||||
|
|
||||||
Since mods can't directly access the savefile, this mod takes it upon itself to track wich items are picked up. This means that the first time you install this mod, everything will be marked as unseen.
|
Since mods can't directly access the savefile, this mod takes it upon itself to track wich items are picked up. This means that the first time you install this mod, everything will be marked as unseen.
|
||||||
|
|
||||||
Turns out EID already has some 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
|
Turns out EID already have some 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
|
||||||
|
|
||||||
However, EID's save extractor doesn't really work on Linux, so I made a port of it in python, in order to be more easily ran. This port is available here : https://forge.chapril.org/ayte/DeadGodHelper/src/branch/main/SaveExtractor
|
However, EID's save extractor doesn't really work on Linux, so I made a port of it in python, in order to be more easily ran. This port is available here : https://forge.chapril.org/ayte/DeadGodHelper/src/branch/main/SaveExtractor
|
||||||
This port can also extract save file's info to be used for Dead God Helper.
|
This port can also extract save file's info to be used for Dead God Helper.
|
||||||
|
Loading…
Reference in New Issue
Block a user