Using repentogon better callbacks if available
This commit is contained in:
parent
eeba233fc8
commit
d0b2db92f2
59
main.lua
59
main.lua
@ -9,11 +9,14 @@ local save = savegen:new()
|
||||
local json = include("json")
|
||||
local DEBUG = false
|
||||
local getgamedata = Isaac.GetPersistentGameData -- Repentogon exclusive
|
||||
local isrepentogon = getgamedata ~= nil
|
||||
isrepentogon = false
|
||||
|
||||
mod.font = Font()
|
||||
mod.font:Load("font/terminus.fnt")
|
||||
|
||||
function mod:isCurseBlind()
|
||||
function mod:isCurseBlind(pickupEntity)
|
||||
if isrepentogon then return pickupEntity:IsBlind() end
|
||||
return mod.game:GetLevel():GetCurses() & LevelCurse.CURSE_OF_BLIND > 0
|
||||
end
|
||||
|
||||
@ -22,28 +25,27 @@ function mod.isIdNotTakenAlready(id)
|
||||
-- Always returns seen if on a challenge
|
||||
if Isaac.GetChallenge() ~= 0 then return false end
|
||||
|
||||
-- Check using REPENTOGON
|
||||
if getgamedata then
|
||||
if getgamedata():IsItemInCollection(id) then
|
||||
if not save.seen[id] then
|
||||
save:touchid(id)
|
||||
mod:save()
|
||||
end
|
||||
return false
|
||||
if id > save.settings.maxid then
|
||||
if save.settings.showonmodded then
|
||||
local itemconfig = Isaac.GetItemConfig():GetCollectible(id)
|
||||
if itemconfig then
|
||||
local name = itemconfig.Name
|
||||
return not save.seenmodded[name]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
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]
|
||||
else
|
||||
-- Check using REPENTOGON
|
||||
if isrepentogon then
|
||||
if getgamedata():IsItemInCollection(id) then
|
||||
if not save.seen[id] then
|
||||
mod.registerTouched(id)
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
return not save.seen[id]
|
||||
end
|
||||
else
|
||||
return false -- Don't show on empty pedestals
|
||||
end
|
||||
@ -123,7 +125,7 @@ end
|
||||
-- Used to draw the ! sign
|
||||
function mod:PickupDrawCallback(pickupEntity, _)
|
||||
if save.settings.visual and
|
||||
(not mod:isCurseBlind() or save.settings.showonblind) then
|
||||
(not (mod:isCurseBlind(pickupEntity)) or save.settings.showonblind) then
|
||||
if pickupEntity.Variant == PickupVariant.PICKUP_COLLECTIBLE then
|
||||
if mod.isIdNotTakenAlready(pickupEntity.SubType) then
|
||||
local v = Isaac.WorldToScreen(
|
||||
@ -166,7 +168,20 @@ function mod:save() mod:SaveData(save:dump(json)) end
|
||||
mod:AddCallback(ModCallbacks.MC_POST_GAME_END, mod.save)
|
||||
mod:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, mod.newrun)
|
||||
|
||||
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, mod.update)
|
||||
if not isrepentogon then
|
||||
-- Used to check for new items
|
||||
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, mod.update)
|
||||
else
|
||||
function mod.addCollectibleCallaback(_, id, _, _, _, _)
|
||||
print(id)
|
||||
mod.registerTouched(id)
|
||||
end
|
||||
-- This is not a vanilla callback, it is from repentogon
|
||||
mod:AddCallback(ModCallbacks.MC_POST_ADD_COLLECTIBLE,
|
||||
mod.addCollectibleCallaback)
|
||||
end
|
||||
|
||||
-- Used to draw indicators
|
||||
mod:AddCallback(ModCallbacks.MC_POST_PICKUP_RENDER, mod.PickupDrawCallback)
|
||||
|
||||
if EID then
|
||||
|
Loading…
Reference in New Issue
Block a user