Improved Luadocs and fixed some code warnings

This commit is contained in:
Wofsauge committed 2025-01-24 00:19:16 +01:00
1 parent 38fbb8a473
commit 97cbaecc42
4 files changed
+57 -64

No files matched your search

+36 -36
View File
@@ -113,7 +113,7 @@ local dynamicSpriteCache = {} -- used to store sprite objects of collectible ico
---@field Quality integer
---@field Icon EID_Icon
---@field Entity Entity?
---@field ShowWhenUndefined boolean
---@field ShowWhenUnidentified boolean?
---@field PermanentTextEnglish string?
---@field ItemType integer?
---@field ChargeType integer?
@@ -304,7 +304,7 @@ end
--- EID:assignTransformation("collectible", 1, "My Transformation")
--- ```
--- <hr>
---@param targetType? EID_TypeVariantAlias @Alias for a `Type.Variant` of entity
---@param targetType EID_TypeVariantAlias @Alias for a `Type.Variant` of entity
---@param targetIdentifier integer | string @If valid `targetType` is specified, `SubType` of the entity. Otherwise, the full entity identifier
---@param transformationString string @Transformation name
function EID:assignTransformation(targetType, targetIdentifier, transformationString)
@@ -355,7 +355,7 @@ end
---EID:removeTransformation("collectible", 1, "My Transformation")
---```
---<hr>
---@param targetType? EID_TypeVariantAlias @Alias for a `Type.Variant` of entity
---@param targetType EID_TypeVariantAlias @Alias for a `Type.Variant` of entity
---@param targetIdentifier integer | string @If valid `targetType` is specified, `SubType` of the entity. Otherwise, the full entity identifier
---@param transformationString string @Transformation name
function EID:removeTransformation(targetType, targetIdentifier, transformationString)
@@ -469,7 +469,7 @@ end
---@see EID.hidePermanentText @Hides permanently displayed text object.
---@param descriptionObject EID_DescObj @Description object to display
---@param permName1 string
---@param permName2 string
---@param permName2 string?
function EID:displayPermanentText(descriptionObject, permName1, permName2)
descriptionObject.PermanentTextEnglish = EID:getDescriptionEntryEnglish(permName1, permName2)
EID.permanentDisplayTextObj = descriptionObject
@@ -601,7 +601,7 @@ end
---Returns the description object of the specified entity.
---Falls back to english if the objID isnt available
---@param Type EntityType
---@param Type EntityType | integer
---@param Variant integer
---@param SubType integer
---@param entity? Entity
@@ -729,17 +729,17 @@ end
---Returns the specified object string in the current language.
---Falls back to english if it doesnt exist, unless `noFallback` is true
---@param objTable string
---@param objID? integer
---@param objIdentifier? integer | string
---@param noFallback? boolean
---@return string
function EID:getDescriptionEntry(objTable, objID, noFallback)
if not objID then
function EID:getDescriptionEntry(objTable, objIdentifier, noFallback)
if not objIdentifier then
if noFallback then return EID.descriptions[EID:getLanguage()][objTable]
else return EID.descriptions[EID:getLanguage()][objTable] or EID.descriptions["en_us"][objTable] end
else
local translatedTable = EID.descriptions[EID:getLanguage()][objTable]
if noFallback then return translatedTable and translatedTable[objID]
else return (translatedTable and translatedTable[objID]) or (EID.descriptions["en_us"][objTable] and EID.descriptions["en_us"][objTable][objID]) end
if noFallback then return translatedTable and translatedTable[objIdentifier]
else return (translatedTable and translatedTable[objIdentifier]) or (EID.descriptions["en_us"][objTable] and EID.descriptions["en_us"][objTable][objIdentifier]) end
end
end
@@ -913,12 +913,12 @@ end
---@param id PlayerType
---@return string?
function EID:findPlayerName(id)
local found, entityPlayer = EID:PlayersHaveCharacter(id, false)
local _, entityPlayer = EID:PlayersHaveCharacter(id, false)
if entityPlayer then return entityPlayer:GetName() end
end
---Returns the name of a pill based on the pilleffect id
---@param pillID PillEffect
---@param pillID PillEffect | integer
---@param isHorsepill boolean
---@return string
function EID:getPillName(pillID, isHorsepill)
@@ -1191,7 +1191,7 @@ end
---Searches through the given string and replaces Icon placeholders with icons.
---Returns 2 values. the string without the placeholders but with an accurate space between lines. And a table of all Inline Sprites
---@param text string
---@param renderBulletPointIcon boolean
---@param renderBulletPointIcon boolean?
---@return string, [EID_Icon, integer, function?][]
function EID:filterIconMarkup(text, renderBulletPointIcon)
local spriteTable = {}
@@ -1241,9 +1241,9 @@ end
---@param spriteObj Sprite
---@param posX integer
---@param posY integer
---@param callback fun(spriteObj: Sprite)
---@param animName string
---@param animFrame integer
---@param callback fun(spriteObj: Sprite) | nil
---@param animName string | nil
---@param animFrame integer | nil
function EID:renderIcon(spriteObj, posX, posY, callback, animName, animFrame)
spriteObj.Scale = Vector(EID.Scale, EID.Scale)
spriteObj.Color = Color(1, 1, 1, EID.Config["Transparency"], 0, 0, 0)
@@ -1487,7 +1487,7 @@ end
---@param position Vector
---@param scale Vector
---@param kcolor KColor
---@param renderBulletPointIcon boolean
---@param renderBulletPointIcon boolean?
---@return KColor
function EID:renderString(str, position, scale, kcolor, renderBulletPointIcon)
str = EID:replaceShortMarkupStrings(str)
@@ -1583,18 +1583,18 @@ function EID:SplitTVS(tvsString)
end
---Checks if any player has a given item ID (or anyone is a given player ID)
---@param Type EntityType
---@param Var integer
---@param Sub integer
---@return boolean
---@param Type string | integer | EntityType
---@param Var integer | nil
---@param Sub integer | nil
---@return boolean, EntityPlayer?, integer?
function EID:PlayersHaveItem(Type, Var, Sub)
-- convert "5.100.69" format strings into type, var, sub
if type(Type) == "string" then
Type, Var, Sub = EID:SplitTVS(Type)
-- assume collectible if only Type was given
elseif Var == nil then Sub = Type; Type = 5; Var = 100 end
if Type == 1 then return EID:PlayersHaveCharacter(Sub)
elseif Type == 5 then
if Type == 1 and Sub then return EID:PlayersHaveCharacter(Sub)
elseif Type == 5 and Sub then
if Var == 100 then return EID:PlayersHaveCollectible(Sub)
elseif Var == 350 then return EID:PlayersHaveTrinket(Sub)
elseif Var == 300 then return EID:PlayersHaveCard(Sub)
@@ -1607,8 +1607,8 @@ end
---Checks if the given player has the given item ID (or is the given player ID)
---@param player EntityPlayer
---@param Type EntityType
---@param Var integer
---@param Sub integer
---@param Var integer?
---@param Sub integer?
---@return boolean
function EID:PlayerHasItem(player, Type, Var, Sub)
-- convert "5.100.69" format strings into type, var, sub
@@ -1616,8 +1616,8 @@ function EID:PlayerHasItem(player, Type, Var, Sub)
Type, Var, Sub = EID:SplitTVS(Type)
-- assume collectible if only Type was given
elseif Var == nil then Sub = Type; Type = 5; Var = 100 end
if Type == 1 then return player:GetPlayerType() == Sub
elseif Type == 5 then
if Type == 1 and Sub then return player:GetPlayerType() == Sub
elseif Type == 5 and Sub then
if Var == 100 then return player:HasCollectible(Sub)
elseif Var == 350 then return player:HasTrinket(Sub)
elseif Var == 300 then return EID:PlayerHasCard(player, Sub)
@@ -1929,7 +1929,7 @@ end
---Converts a given table into a string containing the crafting icons of the table, which are also grouped to reduce render lag
---@param craftTable integer[] @Example: {1,1,1,2,2,3,3,3}
---@param indicateCompleteContent boolean
---@param indicateCompleteContent boolean?
---@return string @Example: "3{{Crafting1}}2{{Crafting2}}3{{Crafting3}}"
function EID:tableToCraftingIconsMerged(craftTable, indicateCompleteContent)
local sortedList = {table.unpack(craftTable)}
@@ -2062,7 +2062,7 @@ function EID:setEntityData(entity, str, value)
end
---Function to fix font compatibility. Resets config font to a value compatible with your current language
---@param forceRefresh boolean
---@param forceRefresh boolean | nil
---@return boolean @True if the font was changed
function EID:fixDefinedFont(forceRefresh)
local curLang = EID:getLanguage()
@@ -2293,7 +2293,7 @@ end
---Returns true if any player is pressing the given button (you can also specify any of the input functions)
---@generic BTN
---@param button BTN
---@param inputFunc fun(button: BTN, playerIndex: integer): boolean
---@param inputFunc nil | fun(button: BTN, playerIndex: integer): boolean
---@return boolean, integer?
function EID:PlayersActionPressed(button, inputFunc)
inputFunc = inputFunc or Input.IsActionPressed
@@ -2903,7 +2903,7 @@ function EID:UpdateAllPlayerLemegetonWisps()
end
end
-- Sort wisps by age (newest first), and leave just the IDs
for playerNum,wisps in pairs(EID.WispsPerPlayer) do
for playerNum, wisps in pairs(EID.WispsPerPlayer) do
table.sort(wisps, function(a, b) return a.FrameCount < b.FrameCount end)
for i,v in ipairs(wisps) do wisps[i] = v.SubType end
end
@@ -2916,7 +2916,7 @@ EID.GlitchedCrownCheck = {}
function EID:WatchForGlitchedCrown()
if REPENTOGON then
-- In REPENTOGON, always check even without Glitched Crown, allowing to check 5+ Soul of Isaac usage, or Everything Jar
local curRoomIndex = game:GetLevel():GetCurrentRoomDesc().ListIndex
local curRoomIndex = game:GetLevel():GetCurrentRoomIndex()
EID.GlitchedCrownCheck[curRoomIndex] = EID.GlitchedCrownCheck[curRoomIndex] or {}
for _, entity in ipairs(Isaac.FindByType(5, 100, -1, true, false)) do
@@ -2935,7 +2935,7 @@ function EID:WatchForGlitchedCrown()
else
if not EID.collectiblesOwned[689] then return end
local curRoomIndex = game:GetLevel():GetCurrentRoomDesc().ListIndex
local curRoomIndex = game:GetLevel():GetCurrentRoomIndex()
EID.GlitchedCrownCheck[curRoomIndex] = EID.GlitchedCrownCheck[curRoomIndex] or {}
for _, entity in ipairs(Isaac.FindByType(5, 100, -1, true, false)) do
@@ -2954,8 +2954,8 @@ end
---Example: "My {1} message" --> "My test message"
---varID can be omitted to replace {1} (or pass in a string table, to replace {1}, {2}, etc.)
---@param str string
---@param varID integer | integer[]
---@param newString? string | string[]
---@param varID integer | integer[] | string | string[]
---@param newString? string | string[] | integer
function EID:ReplaceVariableStr(str, varID, newString)
if newString == nil then
newString = varID ---@diagnostic disable-line
@@ -3019,7 +3019,7 @@ end
---Simple decimal rounding, instead of just floor or ceil
---@param num number
---@param dp integer
---@param dp integer?
---@return number
function EID:SimpleRound(num, dp)
dp = dp or 2
+13 -18
View File
@@ -310,8 +310,8 @@ function EID:ClosestCharCheck(modifierText, playerTypes, includeTainted)
end
-- The closest player does not apply the modifier; check for players that do get this modifier
for i = 1, #EID.coopAllPlayers do
local t = EID.coopAllPlayers[i]:GetPlayerType()
for _, player in ipairs(EID.coopAllPlayers) do
local t = player:GetPlayerType()
if EID:ArrayContains(playerTypes, t) or (includeTainted and EID:ArrayContains(playerTypes, EID.TaintedToRegularID[t])) then
table.insert(EID.DifferentEffectPlayers, t)
end
@@ -320,8 +320,7 @@ function EID:ClosestCharCheck(modifierText, playerTypes, includeTainted)
end
function EID:PlayersHaveGoldenBomb()
for i = 1, #EID.coopAllPlayers do
local player = EID.coopAllPlayers[i]
for _, player in ipairs(EID.coopAllPlayers) do
if player:HasGoldenBomb() then
return true
end
@@ -364,8 +363,7 @@ function EID:CheckForNoRedHealthPlayer()
local player = EID.ItemReminderPlayerEntity
return EID.NoRedHeartsPlayerIDs[player:GetPlayerType()]
else
for i = 1, #EID.coopAllPlayers do
local player = EID.coopAllPlayers[i]
for _, player in ipairs(EID.coopAllPlayers) do
if EID.NoRedHeartsPlayerIDs[player:GetPlayerType()] then
return true
end
@@ -379,8 +377,7 @@ function EID:CheckForTaintedPlayer()
local player = EID.ItemReminderPlayerEntity
return EID.TaintedIDs[player:GetPlayerType()]
else
for i = 1, #EID.coopAllPlayers do
local player = EID.coopAllPlayers[i]
for _, player in ipairs(EID.coopAllPlayers) do
if EID.TaintedIDs[player:GetPlayerType()] then
return true
end
@@ -390,15 +387,14 @@ function EID:CheckForTaintedPlayer()
end
-- Check if we have characters with Schoolbag or a pocket active item
function EID:CheckForMultipleActives(descObj, onlyChargeablePockets)
function EID:CheckForMultipleActives(_, onlyChargeablePockets)
if EID.InsideItemReminder then
local player = EID.ItemReminderPlayerEntity
if player:HasCollectible(534) then return 534 end
local id = player:GetPlayerType()
if EID.isRepentance and (EID.PocketActivePlayerIDs[id] == 0 or (not onlyChargeablePockets and EID.PocketActivePlayerIDs[id])) then return player:GetActiveItem(2) end
else
for i = 1, #EID.coopAllPlayers do
local player = EID.coopAllPlayers[i]
for _, player in ipairs(EID.coopAllPlayers) do
if player:HasCollectible(534) then return 534 end
local id = player:GetPlayerType()
if EID.isRepentance and (EID.PocketActivePlayerIDs[id] == 0 or (not onlyChargeablePockets and EID.PocketActivePlayerIDs[id])) then return player:GetActiveItem(2) end
@@ -416,8 +412,7 @@ function EID:CheckForPocketActives()
local player = EID.ItemReminderPlayerEntity
return EID.PocketActivePlayerIDs[player:GetPlayerType()]
else
for i = 1, #EID.coopAllPlayers do
local player = EID.coopAllPlayers[i]
for _, player in ipairs(EID.coopAllPlayers) do
if EID.PocketActivePlayerIDs[player:GetPlayerType()] then return true end
end
end
@@ -430,14 +425,14 @@ function EID:CheckForCarBattery(descObj)
return descObj.ObjSubType
end
-- When we're looking at a Car Battery pedestal, check our actives for having an effect or no effect
function EID:CheckActivesForCarBattery(descObj)
function EID:CheckActivesForCarBattery(_)
if EID.InsideItemReminder then return false end
for k,v in pairs(EID.CarBatteryPedestalWhitelist) do
if v and EID:PlayersHaveCollectible(k) then return k end
end
return false
end
function EID:CheckActivesForNoCarBattery(descObj)
function EID:CheckActivesForNoCarBattery(_)
if EID.InsideItemReminder then return false end
for k,v in pairs(EID.CarBatteryNoSynergy) do
if v and EID:PlayersHaveCollectible(k) then return k end
@@ -458,21 +453,21 @@ function EID:CheckForHiveMind(descObj)
end
-- When we're looking at a BFFS pedestal, check our familiars for having an effect (only finds the earliest one)
function EID:CheckFamiliarsForBFFS(descObj)
function EID:CheckFamiliarsForBFFS(_)
if EID.InsideItemReminder then return false end
for k,v in pairs(EID.BFFSPedestalWhitelist) do
if v and EID:PlayersHaveCollectible(k) then return "5.100." .. k end
end
return false
end
function EID:CheckFamiliarsForHiveMind(descObj)
function EID:CheckFamiliarsForHiveMind(_)
if EID.InsideItemReminder then return false end
for k,v in pairs(EID.BFFSPedestalWhitelist) do
if EID.HiveMindFamiliars[k] and v and EID:PlayersHaveCollectible(k) then return "5.100." .. k end
end
return false
end
function EID:CheckFamiliarsForNoBFFS(descObj)
function EID:CheckFamiliarsForNoBFFS(_)
if EID.InsideItemReminder then return false end
for k,v in pairs(EID.BFFSNoSynergy) do
if v and EID:PlayersHaveCollectible(k) then return k end
+1 -3
View File
@@ -14,10 +14,8 @@ function EID:TabReleased() return EID.TabHeldLastFrame and not EID.TabHeldThisFr
-- 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
EID.collectiblesToCheck["5.300.41"] = true -- Black Rune
local maxSlot = 1
-- Repentance modifiers
if EID.isRepentance then
maxSlot = 3
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_BOOK_OF_VIRTUES] = true
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_SPINDOWN_DICE] = true
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_MOMS_BOX] = true
@@ -920,7 +918,7 @@ if EID.isRepentance then
local function GlitchedCrownCallback(descObj)
if not descObj.Entity or inGlitchedCrown then return descObj end
local entity = descObj.Entity
local curRoomIndex = game:GetLevel():GetCurrentRoomDesc().ListIndex
local curRoomIndex = game:GetLevel():GetCurrentRoomIndex()
if EID.GlitchedCrownCheck[curRoomIndex] and EID.GlitchedCrownCheck[curRoomIndex][descObj.Entity.InitSeed .. descObj.Entity.Index] then
-- this table has collectible ID keys that define the first frame and most recent frame that that ID has been seen on this pedestal
+7 -7
View File
@@ -49,7 +49,7 @@ local pathsChecked = {}
local altPathItemChecked = {}
local alwaysUseLocalMode = false -- set to true after drawing a non-local mode description this frame
EID.ForceRefreshCache = false -- set to true to force-refresh descriptions, currently used for potential transformation text changes
EID.holdTabPlayer = 0
EID.holdTabPlayer = nil
EID.holdTabCounter = 0
EID.DInfinityState = {}
local forgottenDropTimer = 0
@@ -294,7 +294,7 @@ if EID.isRepentance then
-- (it also watches for item rerolls to fill the new entity's GetData)
-- POST_NEW_ROOM then handles putting the result in the entity's GetData
local curFrame = Isaac.GetFrameCount()
local curRoomIndex = game:GetLevel():GetCurrentRoomDesc().ListIndex
local curRoomIndex = game:GetLevel():GetCurrentRoomIndex()
if curFrame == lastGetItemResult[2] then
if initialItemNext then lastGetItemResult[1] = selectedCollectible
elseif flipItemNext and lastGetItemResult[1] then
@@ -328,7 +328,7 @@ if EID.isRepentance then
flipItemNext = true
lastGetItemResult[4] = entity.InitSeed
local curRoomIndex = game:GetLevel():GetCurrentRoomDesc().ListIndex
local curRoomIndex = game:GetLevel():GetCurrentRoomIndex()
local gridPos = game:GetRoom():GetGridIndex(entity.Position)
-- Update a Flip item's init seed after D6 rerolls or using Flip (aka Grid Index didn't change, Init Seed did)
@@ -355,7 +355,7 @@ if EID.isRepentance then
-- 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.
if EID:getEntityData(entity, "EID_FlipItemID") and entity.Index > EID.flipMaxIndex then
local curRoomIndex = game:GetLevel():GetCurrentRoomDesc().ListIndex
local curRoomIndex = game:GetLevel():GetCurrentRoomIndex()
local gridPos = game:GetRoom():GetGridIndex(entity.Position)
local flipEntry = EID.flipItemPositions[curRoomIndex] and EID.flipItemPositions[curRoomIndex][entity.InitSeed]
-- only wipe the data if the grid index matches (so Diplopia pedestals don't)
@@ -370,7 +370,7 @@ if EID.isRepentance then
-- also, reload our descriptions due to transformation progress changing upon Flip
EID.ForceRefreshCache = true
lastFrameGridChecked = Isaac.GetFrameCount()
local curRoomIndex = game:GetLevel():GetCurrentRoomDesc().ListIndex
local curRoomIndex = game:GetLevel():GetCurrentRoomIndex()
if EID.flipItemPositions[curRoomIndex] then
local pedestals = Isaac.FindByType(5, 100, -1, true, false)
for _, pedestal in ipairs(pedestals) do
@@ -775,7 +775,7 @@ EID.isDeathCertRoom = false
if EID.isRepentance then
function EID:AssignFlipItems()
EID.flipMaxIndex = -1
local curRoomIndex = game:GetLevel():GetCurrentRoomDesc().ListIndex
local curRoomIndex = game:GetLevel():GetCurrentRoomIndex()
if EID.flipItemPositions[curRoomIndex] then
local pedestals = Isaac.FindByType(5, 100, -1, true, false)
for _, pedestal in ipairs(pedestals) do
@@ -895,7 +895,7 @@ function EID:renderIndicator(entity, playerNum)
end
-- Don't apply sprite.Color changes to Effects (Dice Floors, Card Reading Portals), use Arrow instead
if EID.Config["Indicator"] == "arrow" or entity.Type == 1000 or EID:IsGridEntity(entity) then
if EID.Config["Indicator"] == "arrow" or entity.Type == 1000 or sprite == nil then
ArrowSprite:RenderLayer(playerNum-1, arrowPos, nullVector, nullVector)
else
local colorMult = {1,1,1}