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