diff --git a/features/eid_api.lua b/features/eid_api.lua
index 442a1f8f..7076cef6 100644
--- a/features/eid_api.lua
+++ b/features/eid_api.lua
@@ -173,6 +173,7 @@ end
---@param appendText? string | string[] @Text to be appended onto the description. Can be one string, or a table of two strings; one for doubling and one for tripling
---@param numbersToMultiply? number | number[] @The number inside the text that should be multiplied. can be one number, or a table of numbers
---@param maxMultiplier? number @Is what tripling (Golden+Mom's Box) should multiply the numbers by, normally 3. If it's less than 2, it also applies to doubling
+---@param language? EID_LanguageCode @Default: "en"
-- Example: My modded trinket gives +0.5 range and when tripled, adds homing instead of tripling the range boost:
--- ```lua
--- EID:addGoldenTrinketMetadata(Isaac.GetTrinketIdByName("Cool Trinket"), {"", "Homing tears"}, 0.5, 2)
@@ -194,14 +195,15 @@ function EID:addGoldenTrinketMetadata(id, appendText, numbersToMultiply, maxMult
end
end
---Adds information about appending text and adding to numbers in a modded trinket's Golden/Mom's Box description. All three variables are optional, set to ""/0 or nil to not include them
+---@param id TrinketType
---@param appendText? string | string[] @Text to be appended onto the description. Can be one string, or a table of two strings; one for doubling and one for tripling
---@param numbersToChange? number | number[] @The number inside the text that gets added towards. can be one number, or a table of numbers
---@param additiveValues? number @Table of values that should be added to the number, if its doubled, tripled, or quadrupled
+---@param language? EID_LanguageCode @Default: "en"
-- Example: My modded trinket gives +5 range and when tripled, adds homing instead of tripling the range boost:
--- ```lua
--- EID:addGoldenTrinketMetadataAdditive(Isaac.GetTrinketIdByName("Cool Trinket"), {"", "Homing tears"}, 5, {1,2,3})
--- ```
-
function EID:addGoldenTrinketMetadataAdditive(id, appendText, numbersToChange, additiveValues, language)
language = language or "en"
@@ -223,7 +225,6 @@ end
---Add a fully custom data table to the table of Golden Trinket effects.
---Check GoldenTrinketCallback in [eid_modifiers.lua](eid_modifiers.lua) to see the specifics of how it works.
---You may also want to add text entries into `EID.descriptions[languageCode].goldenTrinketEffects`
----
---@param id TrinketType
---@param dataTable EID_GoldenTrinketData
function EID:addGoldenTrinketTable(id, dataTable)
@@ -247,6 +248,8 @@ function EID:addCard(id, description, itemName, language)
end
-- DEPRECATED! Does nothing! Don't use!
+---@deprecated
+---@diagnostic disable-next-line: unused-local
function EID:addCardMetadata(id, mimicCharge, isRune)
end
@@ -292,6 +295,7 @@ end
---@param id PillEffect
---@param mimicCharge integer @DEPRECATED, does nothing
---@param class? EID_PillClass @Default: "0". With False PHD, "3-" gives +0.6 Damage, "2-" and "1-" spawn a Black Heart
+---@diagnostic disable-next-line: unused-local
function EID:addPillMetadata(id, mimicCharge, class)
EID.pillMetadata[id] = {
class = class or "0",
@@ -1005,8 +1009,9 @@ function EID:getXMLDescription(Type, Variant, SubType)
end
---Check if an entity is part of the describable entities
----@param entity Entity
+---@param entity Entity | GridEntity
---@return boolean
+---@diagnostic disable: param-type-mismatch
---@diagnostic disable-next-line: duplicate-set-field
function EID:hasDescription(entity)
if not EID:EntitySanityCheck(entity) then return false end
@@ -1681,7 +1686,7 @@ end
---Checks if the given player has the given item ID (or is the given player ID)
---@param player EntityPlayer
----@param Type EntityType
+---@param Type EntityType | string
---@param Var integer?
---@param Sub integer?
---@return boolean
diff --git a/features/eid_holdmapdesc.lua b/features/eid_holdmapdesc.lua
index e0db0a2f..e9507045 100644
--- a/features/eid_holdmapdesc.lua
+++ b/features/eid_holdmapdesc.lua
@@ -506,7 +506,8 @@ function EID:ItemReminderAddSpecialDescriptions(player)
end
end
--- Information about the player character's traits
+-- Item Reminder function: Information about the player character's traits
+---@param player EntityPlayer
function EID:ItemReminderHandleCharacterInfo(player)
local playerType = player:GetPlayerType()
local playerDesc = EID:getDescriptionEntry("CharacterInfo")[playerType]
@@ -515,7 +516,8 @@ function EID:ItemReminderHandleCharacterInfo(player)
end
end
--- Passive Item Descriptions
+-- Item Reminder function: Passive Item Descriptions
+---@param player EntityPlayer
function EID:ItemReminderHandleSelectedPassiveItem(player)
local playerNum = EID:getPlayerID(player, true)
if EID.RecentlyTouchedItems[playerNum] and #EID.RecentlyTouchedItems[playerNum] > 0 then
@@ -523,7 +525,8 @@ function EID:ItemReminderHandleSelectedPassiveItem(player)
end
end
--- Active Item Descriptions
+-- Item Reminder function: Active Item Descriptions
+---@param player EntityPlayer
function EID:ItemReminderHandleActiveItems(player)
-- limit number of active item descriptions to 2, since Slot 3 and 4 are handled seperately
for i = 0, 1 do
@@ -536,7 +539,8 @@ function EID:ItemReminderHandleActiveItems(player)
end
end
--- pocket active
+-- Item Reminder function: pocket actives
+---@param player EntityPlayer
function EID:ItemReminderHandlePocketActive(player)
if not EID.isRepentance or not EID:ItemReminderCanAddMoreToView() then return end
local pocketActive = player:GetActiveItem(2) or 0
@@ -545,7 +549,8 @@ function EID:ItemReminderHandlePocketActive(player)
end
end
--- dice bag
+-- Item Reminder function: dice bag
+---@param player EntityPlayer
function EID:ItemReminderHandleDiceBag(player)
if not EID.isRepentance or not EID:ItemReminderCanAddMoreToView() then return end
@@ -555,7 +560,8 @@ function EID:ItemReminderHandleDiceBag(player)
end
end
--- Pocket Item Descriptions
+-- Item Reminder function: Pocket Item Descriptions
+---@param player EntityPlayer
function EID:ItemReminderHandlePocketItems(player)
for i = 0, 2 do
if not EID:ItemReminderCanAddMoreToView() then return end
@@ -576,7 +582,9 @@ function EID:ItemReminderHandlePocketItems(player)
end
end
--- Held trinkets are added at the end of the table; use this table in descending order
+-- Item Reminder function: Held trinkets are added at the end of the table; use this table in descending order
+---@param player EntityPlayer
+---@diagnostic disable-next-line: duplicate-set-field
function EID:ItemReminderHeldPlusGulped(player)
local playerNum = EID:getPlayerID(player, true)
local newTable = {}
@@ -587,12 +595,14 @@ function EID:ItemReminderHeldPlusGulped(player)
end
return newTable
end
--- Trinket Descriptions
+-- Item Reminder function: Trinket Descriptions
+---@param player EntityPlayer
function EID:ItemReminderHandleTrinkets(player)
EID:ItemReminderHandleItemPrinting(player, EID:ItemReminderHeldPlusGulped(player), 350, true)
end
--- Tainted ??? Poop Descriptions
+-- Item Reminder function: Tainted ??? Poop Descriptions
+---@param player EntityPlayer
function EID:ItemReminderHandlePoopSpells(player)
if EID.isRepentance and player:GetPlayerType() == 25 and EID:ItemReminderCanAddMoreToView() then
local poopInfo = EID:getDescriptionEntry("poopSpells")
@@ -646,13 +656,14 @@ function EID:ItemReminderHandlePoopSpells(player)
end
end
--- Lemegeton wisp descriptions
+-- Item Reminder function: Lemegeton wisp descriptions
+---@param player EntityPlayer
function EID:ItemReminderHandleLemegetonWisps(player)
local playerNum = EID:getPlayerID(player, true)
EID:ItemReminderHandleItemPrinting(player, EID.WispsPerPlayer[playerNum], 100, false)
end
--- Handle scroll inputs
+-- Item Reminder function: Handle scroll inputs
function EID:ItemReminderHandleInputs()
if EID.Config["ItemReminderEnabled"] and EID.Config["ItemReminderDisplayMode"] ~= "Classic" and EID.holdTabCounter >= 30 and EID.TabDescThisFrame == false and EID.holdTabPlayer ~= nil then
if EID.Config["ItemReminderDisableInputs"] then EID.holdTabPlayer.ControlsCooldown = 2 end
@@ -695,10 +706,10 @@ function EID:ItemReminderHandleInputs()
end
end
--- special list of all players, ignoring tainted forgotten ghost and coop babies
+-- Item Reminder function: special list of all players, ignoring tainted forgotten ghost and coop babies
function EID:ItemReminderGetAllPlayers()
local filteredPlayerList = {}
- for i, player in ipairs(EID.coopAllPlayers) do
+ for _, player in ipairs(EID.coopAllPlayers) do
if not (EID.isRepentance and player:GetPlayerType() == PlayerType.PLAYER_THESOUL_B) and player:GetBabySkin() == -1 then
table.insert(filteredPlayerList, player)
end
@@ -706,14 +717,20 @@ function EID:ItemReminderGetAllPlayers()
return filteredPlayerList
end
+-- Item Reminder function: check if the currently selected category is scrollable
+---@return boolean
function EID:IsScrollableCategorySelected()
return EID.ItemReminderCategories[EID.ItemReminderSelectedCategory + 1].isScrollable
end
+-- Item Reminder function: check if the given category is currently selected
+---@param categoryID integer
+---@return boolean
function EID:IsCategorySelected(categoryID)
return EID.ItemReminderCategories[EID.ItemReminderSelectedCategory + 1].id == categoryID
end
+-- Item Reminder function: Resets data when initializing holding TAB
function EID:ItemReminderHandleInitHoldTab()
local oldDisplayPlayer = EID.ItemReminderSelectedPlayer
@@ -734,6 +751,8 @@ function EID:ItemReminderHandleInitHoldTab()
end
end
+--- Returns the title of the currently selected Item Reminder category.
+---@return string
function EID:ItemReminderGetTitle()
local category = EID.ItemReminderCategories[EID.ItemReminderSelectedCategory + 1]
@@ -836,19 +855,21 @@ function EID:ItemReminderHandleItemPrinting(player, entryTable, itemVariant, des
if descending then
local startIndex = (#entryTable - EID.ItemReminderSelectedItems[EID.ItemReminderSelectedCategory] - 1) % #entryTable
- for i = 1, descsToDisplay do
+ for _ = 1, descsToDisplay do
EID:ItemReminderAddDescription(player, 5, itemVariant, entryTable[startIndex+1] % GLITCH_ITEM_FLAG)
startIndex = (startIndex - 1) % #entryTable
end
else
local startIndex = EID.ItemReminderSelectedItems[EID.ItemReminderSelectedCategory] % #entryTable
- for i = 1, descsToDisplay do
+ for _ = 1, descsToDisplay do
EID:ItemReminderAddDescription(player, 5, itemVariant, entryTable[startIndex+1] % GLITCH_ITEM_FLAG)
startIndex = (startIndex + 1) % #entryTable
end
end
end
+--- Generates the description for the Item Reminder, based on the currently selected category and player.
+---@return string
function EID:ItemReminderGetDescription()
EID.InsideItemReminder = true
EID.ItemReminderTempDescriptions = {}
diff --git a/features/eid_modifiers.lua b/features/eid_modifiers.lua
index 70d743d2..d60f36b3 100644
--- a/features/eid_modifiers.lua
+++ b/features/eid_modifiers.lua
@@ -8,8 +8,15 @@ EID.TabDescThisFrame = false
-- Some modifiers (e.g. Glitched Crown) want to know if Tab was pressed/released, rather than held
EID.TabHeldThisFrame = false
EID.TabHeldLastFrame = false
-function EID:TabPressed() return EID.TabHeldThisFrame and not EID.TabHeldLastFrame end
-function EID:TabReleased() return EID.TabHeldLastFrame and not EID.TabHeldThisFrame end
+
+-- Returns true if Tab was pressed this frame, false otherwise
+function EID:TabPressed()
+ return EID.TabHeldThisFrame and not EID.TabHeldLastFrame
+end
+-- Returns true if Tab was released this frame, false otherwise
+function EID:TabReleased()
+ return EID.TabHeldLastFrame and not EID.TabHeldThisFrame
+end
-- List of collectible IDs for us to check if a player owns them; feel free to add to this in mods that add description modifiers!
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_VOID] = true
@@ -32,6 +39,7 @@ EID.collectiblesOwned = {}
EID.collectiblesAbsorbed = {}
EID.LastCollectibleCheck = 0
+-- Check if any players own a collectible, returns true if at least one player has it
function EID:CheckPlayersCollectibles()
-- recheck the players' owned collectibles periodically, not every frame
-- (has to be checked regularly due to mechanics like D4 / Tainted Eden)
diff --git a/main.lua b/main.lua
index b053f6b0..ad935930 100644
--- a/main.lua
+++ b/main.lua
@@ -86,6 +86,12 @@ local hudBBSprite = Sprite()
hudBBSprite:Load("gfx/eid_transform_icons.anm2", true)
hudBBSprite:Play("boundingBox")
+local questionMarkSprite = Sprite()
+questionMarkSprite:Load("gfx/005.100_collectible.anm2",true)
+questionMarkSprite:ReplaceSpritesheet(1,"gfx/items/collectibles/questionmark.png")
+questionMarkSprite:LoadGraphics()
+
+
EID.ModIndicator = { }
-- Overwriting "RegisterMod" to track which mods are loading
@@ -133,6 +139,8 @@ local nullVector = Vector(0,0)
------------------------------- Load Font ---------------------------------
local modfolder ='external item descriptions_836319872' --release mod folder name
+--- Function to get the current mod path
+--- @return string The absolute path to the current mod
function EID:GetCurrentModPath()
if debug then
return string.sub(debug.getinfo(EID.GetCurrentModPath).source,2) .. "/../"
@@ -173,8 +181,7 @@ if not success then
end
end
----------------------------------------------------------------------------
--------------Handle Resetting Floor Trackers--------------
+--- Function to reset all floor trackers when a new floor is entered
function EID:onNewFloor()
pathsChecked = {}
if EID.isRepentance then
@@ -187,14 +194,7 @@ function EID:onNewFloor()
end
EID:AddCallback(ModCallbacks.MC_POST_NEW_LEVEL, EID.onNewFloor)
----------------------------------------------------------------------------
-------------------------Handle ALT FLOOR CHOICE----------------------------
-
-local questionMarkSprite = Sprite()
-questionMarkSprite:Load("gfx/005.100_collectible.anm2",true)
-questionMarkSprite:ReplaceSpritesheet(1,"gfx/items/collectibles/questionmark.png")
-questionMarkSprite:LoadGraphics()
-
+--- Function to check if a collectible pedestal is an alt path choice
function EID:IsAltChoice(pickup)
-- do not run this while Curse of the Blind is active, since this function is really just a "is collectible pedestal a red question mark" check
if not EID.isRepentance or EID:hasCurseBlind() then
@@ -250,6 +250,9 @@ if EID.isRepentance then
local lastGetItemResult = {nil, nil, nil, nil} -- itemID, Frame, gridIndex, InitSeed
local lastFrameGridChecked = 0
+ --- Handle Flip Item positions and Crane Game item positions. Repentance Only function!
+ ---@param selectedCollectible number
+ ---@param itemPoolType number
function EID:postGetCollectible(selectedCollectible, itemPoolType)
-- Handle Crane Game
if itemPoolType == ItemPoolType.POOL_CRANE_GAME then
@@ -284,7 +287,11 @@ if EID.isRepentance then
end
EID:AddCallback(ModCallbacks.MC_POST_GET_COLLECTIBLE, EID.postGetCollectible)
- -- Handle Flip Item spawn
+ --- Pre Room Entity Spawn callback to handle Flip item and pedestal spawning. Repentance Only function!
+ ---@param entityType any
+ ---@param variant any
+ ---@param subtype any
+ ---@param gridIndex any
function EID:preRoomEntitySpawn(entityType, variant, subtype, gridIndex)
flipItemNext = false
if entityType == 6 and variant == 14 then
@@ -299,6 +306,8 @@ if EID.isRepentance then
end
EID:AddCallback(ModCallbacks.MC_PRE_ROOM_ENTITY_SPAWN, EID.preRoomEntitySpawn)
+ --- Post Pickup Init callback to handle Flip item initialization. Repentance Only function!
+ ---@param entity any
function EID:postPickupInitFlip(entity)
initialItemNext = false
flipItemNext = true
@@ -327,6 +336,8 @@ if EID.isRepentance then
end
EID:AddCallback(ModCallbacks.MC_POST_PICKUP_INIT, EID.postPickupInitFlip, PickupVariant.PICKUP_COLLECTIBLE)
+ --- Check if a pedestal's index is valid for Flip items. Repentance Only function!
+ ---@param entity any
function EID:CheckPedestalIndex(entity)
-- Only pedestals with indexes that were present at room load can be flip pedestals
-- Fixes shop restock machines and Diplopia... mostly. At least while you're in the room.
@@ -342,6 +353,7 @@ if EID.isRepentance then
EID:AddCallback(ModCallbacks.MC_POST_PICKUP_UPDATE, EID.CheckPedestalIndex, PickupVariant.PICKUP_COLLECTIBLE)
-- Before using Flip, swap all flippable pedestal's current item with the flip one (also, fix grid index if needed)
+ -- Repentance only function!
function EID:CheckFlipGridIndexes(collectibleType)
-- also, reload our descriptions due to transformation progress changing upon Flip
EID.ForceRefreshCache = true
@@ -366,7 +378,7 @@ if EID.isRepentance then
EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, EID.CheckFlipGridIndexes, CollectibleType.COLLECTIBLE_FLIP)
end
--- Watch for a Void absorbing active items
+-- MC_PRE_USE_ITEM callback to watch for Void absorbing active items
function EID:CheckVoidAbsorbs(_, _, player)
player = player or EID.player
local playerID = EID:getPlayerID(player, true)
@@ -453,6 +465,7 @@ EID.CachedRenderPoses = {}
EID.descriptionsToPrint = {}
EID.entitiesToPrint = {}
+--- Reset the description cache, used when options change or when printing descriptions
function EID:ResetDescCache()
EID.CachedIcons = {}
EID.CachedStrings = {}
@@ -461,7 +474,9 @@ function EID:ResetDescCache()
EID.previousDescs = {}
end
-
+--- Add a description to the print queue
+---@param desc EID_DescObj | table -- The description object to add
+---@param insertLoc integer | nil
function EID:addDescriptionToPrint(desc, insertLoc)
if desc.Entity and EID.entitiesToPrint[GetPtrHash(desc.Entity)] then return end
if #EID.descriptionsToPrint == EID.Config["MaxDescriptionsToDisplay"] and not insertLoc then return end
@@ -472,12 +487,17 @@ function EID:addDescriptionToPrint(desc, insertLoc)
if desc.Entity then EID.entitiesToPrint[GetPtrHash(desc.Entity)] = true end
end
+--- Add a question mark description to the print queue
+---@param entity Entity
+---@param description string | nil
function EID:addQuestionMarkDescription(entity, description)
EID:addDescriptionToPrint({ Icon = EID.InlineIcons["QuestionMark"], Description = description or "", Entity = entity})
end
local prevPrintFrame = 0
+--- Print all descriptions that are currently in the description table
+--- @param useCached boolean | nil - If true, will use the cached descriptions instead of printing new ones
function EID:printDescriptions(useCached)
prevPrintFrame = EID.GameRenderCount
@@ -513,6 +533,7 @@ function EID:printDescriptions(useCached)
end
end
+--- Print all descriptions that are currently in the description table
function EID:printNewDescriptions()
EID.CachingDescription = true
EID:ResetDescCache()
@@ -533,11 +554,14 @@ function EID:printNewDescriptions()
end
end
+--- Prints a description to the screen
+---@param desc EID_DescObj
+---@param cachedID integer | nil -- If this is a cached description, pass the index of the cached description
function EID:printDescription(desc, cachedID)
EID:PositionLocalMode(desc.Entity)
-- Do not print this description if it has to be drawn in the top-left and we've already drawn a top-left desc this frame
if EID.CurrentScaleType == "Size" then
- if alwaysUseLocalMode then return false
+ if alwaysUseLocalMode then return
else alwaysUseLocalMode = true end
end
EID.isDisplaying = true
@@ -716,6 +740,10 @@ function EID:printDescription(desc, cachedID)
end
end
+--- Prints bullet points from a description string
+---@param description string - The description string to print
+---@param renderPos Vector - The position to render the bullet points at
+---@param ignoreBPConfig boolean - If true, will ignore the bullet point icon configuration
function EID:printBulletPoints(description, renderPos, ignoreBPConfig)
local textboxWidth = tonumber(EID.Config["TextboxWidth"])
local textScale = Vector(EID.Scale, EID.Scale)
@@ -752,6 +780,7 @@ end
EID.isMirrorRoom = false
EID.isDeathCertRoom = false
if EID.isRepentance then
+ --- Handle Flip Item in New Room. Repentance only function!
function EID:AssignFlipItems()
EID.flipMaxIndex = -1
local curRoomIndex = game:GetLevel():GetCurrentRoomIndex()
@@ -766,6 +795,7 @@ if EID.isRepentance then
end
end
end
+ --- Handle MC_POST_NEW_ROOM for Repentance features
function EID:onNewRoomRep()
local level = game:GetLevel()
EID.isMirrorRoom = level:GetCurrentRoom():IsMirrorWorld()
@@ -779,7 +809,7 @@ if EID.isRepentance then
end
EID:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, EID.onNewRoomRep)
end
-
+--- MC_POST_NEW_ROOM callback to handle new rooms, mostly Glowing Hour Glass rewinding and Grid Entities
function EID:onNewRoom()
EID:CheckCurrentRoomGridEntities()
-- Store values here to be rewound after using Glowing Hour Glass
@@ -797,11 +827,15 @@ end
EID:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, EID.onNewRoom)
---------------------------------------------------------------------------
---------------------------Handle Rendering--------------------------------
+-- RGB colors for each player's highlights (Red, Blue, Yellow, Green)
+local playerRGB = { {1,0.6,0.6}, {0.5,0.75,1}, {0.9, 0.9, 0.5}, {0.5,1,0.75} }
+--- Render an unidentified pill description
+---@param entity Entity
function EID:renderUnidentifiedPill(entity)
EID:PositionLocalMode(entity)
if EID.CurrentScaleType == "Size" then
- if alwaysUseLocalMode then return false
+ if alwaysUseLocalMode then return
else alwaysUseLocalMode = true end
end
EID.isDisplaying = true
@@ -841,10 +875,9 @@ function EID:renderUnidentifiedPill(entity)
end
end
--- RGB colors for each player's highlights (Red, Blue, Yellow, Green)
-local playerRGB = { {1,0.6,0.6}, {0.5,0.75,1}, {0.9, 0.9, 0.5}, {0.5,1,0.75} }
-
+--- Render an indicator for an entity, such as a highlight or arrow
---@param entity Entity
+---@param playerNum integer - The player number to render the indicator for. Controls the arrow color
function EID:renderIndicator(entity, playerNum)
if EID.Config["Indicator"] == "none" then
return
@@ -912,6 +945,7 @@ function EID:renderIndicator(entity, playerNum)
end
end
+--- Position the description box in Local Mode, next to the item or entity
---@param entity Entity
---@diagnostic disable-next-line: duplicate-set-field
function EID:PositionLocalMode(entity)
@@ -944,6 +978,7 @@ function EID:PositionLocalMode(entity)
end
end
+--- Render HUD location indicators for debugging purposes
function EID:renderHUDLocationIndicators()
local mousePos = Isaac.WorldToRenderPosition(Input.GetMousePosition(true)) * 2
Isaac.RenderScaledText("Mouse pos X:"..mousePos.X.." Y:"..mousePos.Y, 100, 10, 0.5, 0.5, 1 ,1 ,1 ,1 )
@@ -960,6 +995,8 @@ end
local lastMousePos = Vector(0,0)
local lastMouseMove = 0
+--- Handle the HUD hover functionality, checking if the mouse is over any HUD elements
+--- @return EID_DescObj | nil - Returns the description object if the mouse is over a HUD element, otherwise nil
function EID:handleHoverHUD()
local mousePos = Isaac.WorldToScreen(Input.GetMousePosition(true)) * 2
if mousePos:Distance(lastMousePos) > 2 then
@@ -982,6 +1019,7 @@ function EID:handleHoverHUD()
return nil
end
+--- Set the player and coop player data for EID
function EID:setPlayer()
local numPlayers = game:GetNumPlayers()
-- Old simple setPlayer, to reduce runtime in single player
@@ -1034,12 +1072,13 @@ end
---------------------------------------------------------------------------
---------------------------On Update Function------------------------------
--- Runs 30 times a second; doesn't update while paused
local collSpawned = false
EID.RecheckVoid = false
EID.ShouldCheckWisp = false
+--- MC_POST_UPDATE callback that runs 30 times a second; doesn't update while paused
+--- Handles updating the game state and checking for new items
function EID:onGameUpdate()
EID.GameUpdateCount = EID.GameUpdateCount + 1
EID:checkPlayersForMissingItems()
@@ -1128,6 +1167,7 @@ local function attemptPathfind(entity)
end
local hasShownStartWarning = false
+--- Check for start of run warnings, such as old game version or modded items
function EID:CheckStartOfRunWarnings()
if EID.isRepentance and not EID.Config["DisableStartOfRunWarnings"] and game:GetFrameCount() < 10*30 then
-- Old Repentance version check; update this to check for the existence of the newest mod API function EID uses
@@ -1228,6 +1268,7 @@ EID.lastDist = 0
EID.OptionChanged = false
EID.bagPlayer = nil
+--- Render function that runs every frame and handles the main EID rendering logic.
function EID:OnRender()
-- Increases by 60 per second, ignores pauses
EID.GameRenderCount = EID.GameRenderCount + 1
@@ -1614,6 +1655,9 @@ end
EID:AddCallback(ModCallbacks.MC_POST_RENDER, EID.OnRender)
+--- Add active item progress to the player's transformation progress.
+---@param player EntityPlayer
+---@param isD4 boolean
local function AddActiveItemProgress(player, isD4)
EID.ForceRefreshCache = true
local playerID = EID:getPlayerID(player, true)
@@ -1635,10 +1679,12 @@ end
-- Check the active items of every player for transformation progress (used at game start and after Genesis)
local function CheckAllActiveItemProgress()
for i = 0, game:GetNumPlayers() - 1 do
- AddActiveItemProgress(Isaac.GetPlayer(i))
+ AddActiveItemProgress(Isaac.GetPlayer(i), false)
end
end
+--- OnGameStartGeneral is called when the game starts, either from a save or a new run.
+--- It initializes various EID tables and resets item interactions.
local function OnGameStartGeneral(_,isSave)
EID:GetAllPassiveItems()
EID:GetTransformationsOfModdedItems()
@@ -1671,7 +1717,7 @@ local function OnUseD4(_, _, _, player)
end
EID:AddCallback(ModCallbacks.MC_USE_ITEM, OnUseD4, CollectibleType.COLLECTIBLE_D4)
--- Watch for smelting trinkets; includes Gulp and Marbles
+-- MC_PRE_USE_ITEM callback to watch for smelting trinkets; includes Gulp and Marbles
function EID:OnUseSmelter(_, _, _, player)
player = player or EID.player
local playerNum = EID:getPlayerID(player, true)
@@ -1684,7 +1730,7 @@ function EID:OnUseSmelter(_, _, _, player)
end
EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, EID.OnUseSmelter, CollectibleType.COLLECTIBLE_SMELTER)
--- Watch for Glowing Hourglass to revert certain variables
+-- MC_PRE_USE_ITEM callback to watch for Glowing Hourglass to revert certain variables
local function OnUseGlowingHourglass(_, _, _, _)
EID.absorbedItems = EID:CopyTable(preHourglassStatus.absorbedItems)
EID.PlayerItemInteractions = EID:CopyTable(preHourglassStatus.PlayerItemInteractions)
@@ -1721,6 +1767,10 @@ if EID.isRepentance then
EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, OnUseGeneral)
end
+--- OnUsePill is called when a pill is used, and handles pill history tracking and Wild Card effects.
+---@param pillEffectID number The ID of the pill effect being used.
+---@param player EntityPlayer The player using the pill.
+---@param useFlags number Flags indicating how the pill was used (e.g., whether it was used with no animation).
function EID:OnUsePill(pillEffectID, player, useFlags)
player = player or EID.player --AB+ doesn't receive player in callback arguments!
-- get the pill color by checking the player's pocket
@@ -1743,6 +1793,10 @@ function EID:OnUsePill(pillEffectID, player, useFlags)
end
EID:AddCallback(ModCallbacks.MC_USE_PILL, EID.OnUsePill)
+--- OnUseCard is called when a card is used, and handles card history tracking and Wild Card effects.
+---@param cardID number The ID of the card being used.
+---@param player EntityPlayer The player using the card.
+---@param useFlags number Flags indicating how the card was used (e.g., whether it was used with no animation).
function EID:OnUseCard(cardID, player, useFlags)
player = player or EID.player --AB+ doesn't receive player in callback arguments!
EID:AddPickupToHistory("card", cardID, player, useFlags)
@@ -1771,6 +1825,11 @@ local configIgnoreList = {
--------------------------------
--------Handle Savedata---------
--------------------------------
+
+
+--- OnGameStart is called when the game starts, either from a save or a new run.
+--- It initializes the config data if available.
+---@param isSave boolean Indicates whether the game is starting from a save or a new run.
function EID:OnGameStart(isSave)
--Loading Moddata--
if EID:HasData() then
@@ -1881,7 +1940,7 @@ function EID:OnGameStart(isSave)
end
EID:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, EID.OnGameStart)
---Saving Moddata--
+--- OnGameExit saves the current EID configuration.
function EID:OnGameExit()
if EID.isRepentance then
EID.Config["BagContent"] = EID.BoC.BagItems or {}