From 08b8b07b1ad4a2e86454a095770f02a80b4ad8fd Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Wed, 3 Jan 2024 23:21:59 +0100 Subject: [PATCH] Added first wave of Repentogon features --- eid_api.lua | 12 ++++++++++-- eid_itemprediction.lua | 2 +- eid_repentogon.lua | 30 ++++++++++++++++++++++++++++++ eid_tmtrainer.lua | 2 +- main.lua | 4 ++++ 5 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 eid_repentogon.lua diff --git a/eid_api.lua b/eid_api.lua index 1529340e..b8585dbc 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -608,7 +608,7 @@ function EID:getObjectName(Type, Variant, SubType) elseif tableName == "dice" then return EID:getDescriptionEntry("diceHeader").." ("..SubType..")" elseif tableName == "custom" then - local xmlName = EID.XMLEntityNames[Type.."."..Variant] or EID.XMLEntityNames[Type.."."..Variant.."."..SubType] + local xmlName = EID:GetEntityXMLName(Type, Variant, SubType) return name or xmlName or Type.."."..Variant.."."..SubType end return Type.."."..Variant.."."..SubType @@ -1702,7 +1702,10 @@ function EID:evaluateTransformationProgress(transformation) if not EID.TransformationLookup[transformation] then return end - if transformData and transformData.VanillaForm and player:HasPlayerForm(transformData.VanillaForm) then + if REPENTOGON and transformData and transformData.VanillaForm then + -- REPENTOGON lets us ignore everything else for vanilla transformation progress + EID.TransformationProgress[i][transformation] = player:GetPlayerFormCounter(transformData.VanillaForm) + elseif transformData and transformData.VanillaForm and player:HasPlayerForm(transformData.VanillaForm) then EID.TransformationProgress[i][transformation] = transformData.NumNeeded or 3 else local pickupHistory = EID.PlayerItemInteractions[i].pickupHistory @@ -1958,3 +1961,8 @@ end function EID:WasPillUsed(pillColor) return EID.UsedPillColors[tostring(pillColor)] ~= nil end + +-- returns the name of the given entity +function EID:GetEntityXMLName(Type, Variant, SubType) + return EID.XMLEntityNames[Type.."."..Variant] or EID.XMLEntityNames[Type.."."..Variant.."."..SubType] +end diff --git a/eid_itemprediction.lua b/eid_itemprediction.lua index 96558c86..6663b8ce 100644 --- a/eid_itemprediction.lua +++ b/eid_itemprediction.lua @@ -324,5 +324,5 @@ function EID:D1Prediction(rng) end local pickupNames = EID:getDescriptionEntry("PickupNames") or {} - return pickupNames[fullID] or EID.XMLEntityNames[fullID] or fullID + return pickupNames[fullID] or EID:GetEntityXMLName(Type, Variant, SubType) or fullID end diff --git a/eid_repentogon.lua b/eid_repentogon.lua new file mode 100644 index 00000000..23278456 --- /dev/null +++ b/eid_repentogon.lua @@ -0,0 +1,30 @@ +if not REPENTOGON then + return +end +---@diagnostic disable: duplicate-set-field +local game = Game() + +-- REPENTOGON: Use PersistentGameData to determine item collection status +-- Returns true if an item needs to be collected for the collection page +function EID:requiredForCollectionPage(itemID) + if itemID >= CollectibleType.NUM_COLLECTIBLES or game:GetVictoryLap() > 0 or game:GetSeeds():IsCustomRun() then return false end + return not Isaac.GetPersistentGameData():IsItemInCollection(itemID) +end + +-- REPENTOGON: Function is no longer used since we can directly read the collection state from the game +function EID:checkPlayersForMissingItems() end + +-- REPENTOGON: Function is no longer used since repentogon always has progress enabled. +function EID:AreAchievementsAllowed() return true end + +-- REPENTOGON: Entity names can now be directly read from XML +-- returns the name of the given entity +function EID:GetEntityXMLName(Type, Variant, SubType) + local xmlEntry = XMLData.GetEntityByTypeVarSub(Type, Variant, SubType) + return xmlEntry and xmlEntry.name or EID.XMLEntityNames[Type .. "." .. Variant] or + EID.XMLEntityNames[Type .. "." .. Variant .. "." .. SubType] +end + +-- Render EID aboth hud, if REPENTOGON is installed +EID:RemoveCallback(ModCallbacks.MC_POST_RENDER, EID.OnRender) +EID:AddCallback(ModCallbacks.MC_HUD_RENDER, EID.OnRender) diff --git a/eid_tmtrainer.lua b/eid_tmtrainer.lua index 85cda20f..cb14a340 100644 --- a/eid_tmtrainer.lua +++ b/eid_tmtrainer.lua @@ -37,7 +37,7 @@ local function entityToName(e, plural) -- -1 is often used as an "any of this type", even if there's only one of that type, so converting it to 0 can help find names local eWithZero = string.gsub(e, "-1", "0") plural = plural or false - local name = localizedNames[e] or EID.XMLEntityNames[e] or localizedNames[eWithZero] or EID.XMLEntityNames[eWithZero] or e + local name = localizedNames[e] or EID:GetEntityXMLName(Type, Variant, SubType) or localizedNames[eWithZero] or e --print out entities with no name yet if name == e then Isaac.DebugString("No name found for " .. e .. " (could be modded)") diff --git a/main.lua b/main.lua index 2aa1912a..2acbe604 100644 --- a/main.lua +++ b/main.lua @@ -1803,7 +1803,11 @@ if EID.enableDebug then require("eid_debugging") end +-- load repentogon stuff last to allow overrides of functions +require("eid_repentogon") + Isaac.DebugString("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") Isaac.DebugString("External Item Descriptions v"..EID.ModVersion.."_"..EID.ModVersionCommit.." loaded.") Isaac.DebugString("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") + print("External Item Descriptions v"..EID.ModVersion.."_"..EID.ModVersionCommit.." loaded.")