Small code cleanup & linting

This commit is contained in:
Wofsauge committed 2022-11-05 23:47:44 +01:00
1 parent 95583c057d
commit 9cbccf5c73
6 files changed
+29 -30

No files matched your search

+3 -3
View File
@@ -1057,7 +1057,7 @@ function EID:renderString(str, position, scale, kcolor)
local textPartsTable = EID:filterColorMarkup(str, kcolor)
local offsetX = 0
for _, textPart in ipairs(textPartsTable) do
local strFiltered, spriteTable = EID:filterIconMarkup(textPart[1], position.X, position.Y)
local strFiltered, spriteTable = EID:filterIconMarkup(textPart[1])
EID:renderInlineIcons(spriteTable, position.X + offsetX, position.Y)
if strFiltered then -- prevent possible crash when strFiltered is nil
EID.font:DrawStringScaledUTF8(strFiltered, position.X + offsetX, position.Y, scale.X, scale.Y, textPart[2], 0, false)
@@ -1073,7 +1073,7 @@ end
-- Adds Description object modifiers.
-- Used for altering descriptions. Example: Spindown dice, Tarot Cloth, ...
function EID:addDescriptionModifier(modifierName, condition, callback)
for i,v in ipairs(EID.DescModifiers) do
for _,v in ipairs(EID.DescModifiers) do
if v["name"] == modifierName then
v["condition"] = condition
v["callback"] = callback
@@ -1238,7 +1238,7 @@ function EID:isCollectibleUnlocked(collectibleID, itemPoolOfItem)
end
end
local isUnlocked = false
for i = 0, 1 do -- some samples to make sure
for _ = 0, 1 do -- some samples to make sure
local collID = itemPool:GetCollectible(itemPoolOfItem, false, 1)
if collID == collectibleID then
isUnlocked = true
+7 -7
View File
@@ -8,7 +8,7 @@ local languageFilesToCheck = {"cs_cz"} -- EID.Languages -- single file check {"k
-- count en_us entries for stats
local count = 0
function EID:countEntries(t)
for k, v in pairs(t) do
for k, _ in pairs(t) do
count = count + 1
if type(t[k]) == "table" then
EID:countEntries(t[k])
@@ -19,11 +19,11 @@ EID:countEntries(EID.descriptions["en_us"])
local enUSEntries = count
print("en_us entries: "..enUSEntries)
for i,lang in ipairs(languageFilesToCheck) do
for _,lang in ipairs(languageFilesToCheck) do
print("Now checking integrity of languagefile: " .. lang)
-- Generic function to compare two tables
function EID:compareTables(table1, table2, prevKey, progress)
for k, v in pairs(table1) do
for k, _ in pairs(table1) do
progress[1] = progress[1] + 1
if not table2[k] then
print(" Table '" .. prevKey .. "' does not contain key: " .. k)
@@ -35,7 +35,7 @@ for i,lang in ipairs(languageFilesToCheck) do
local filteredText = EID:replaceShortMarkupStrings(table2[k])
local textPartsTable = EID:filterColorMarkup(filteredText, EID:getNameColor())
for _, textPart in ipairs(textPartsTable) do
local filteredSpriteText, spriteTable = EID:filterIconMarkup(textPart[1], 0, 0)
local filteredSpriteText, spriteTable = EID:filterIconMarkup(textPart[1])
if string.find(filteredSpriteText, "{{") or string.find(filteredSpriteText, "}}") then
print(" Table '" .. prevKey .. "' entry '" .. k .. "' does contain a broken markup object: '" .. table2[k])
@@ -186,15 +186,15 @@ EID:addColor("ColorBlackBlink", nil, function(color)
-- Test: Pill effect unidentifyable
EID:SetPillEffectUnidentifyable(24, true) -- set "I can see forever" to always be unidentifyable
local function onDebugRender(t)
local function onDebugRender()
EID:renderHUDLocationIndicators()
for i,v in ipairs(Isaac.FindByType(5,10,3,true,false)) do
for _,v in ipairs(Isaac.FindByType(5,10,3,true,false)) do
if v:GetData()["EID_Description"] == nil then
v:GetData()["EID_Description"] = "Test specific description#Init seed: ".. v.InitSeed
end
end
for i,v in ipairs(Isaac.FindByType(5,10,4,true,false)) do
for _,v in ipairs(Isaac.FindByType(5,10,4,true,false)) do
if v:GetData()["EID_Description"] == nil then
local descTable = {
["Name"] = "Some Item with seed ".. v.InitSeed ,
-1
View File
@@ -181,7 +181,6 @@ function EID:getHoldMapDescription(player, checkingTwin)
-- Pocket Item Descriptions
-- Annoying because there's no easy way to just get the info of a slot
if EID.Config["ItemReminderShowPocketDesc"] > 0 then
local numPrinted = 0
-- I don't think we can actually know what slot the player is on, so, save these to display (if they exist) for when Card and Pill in a slot are both 0, to attempt to always show them in slot order
local dicePrinted = false
local diceBag = REPENTANCE and player:GetActiveItem(3) or 0
+3 -3
View File
@@ -39,7 +39,7 @@ if REPENTANCE then
justDidD = true
end
EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, EID.WatchForDInfinity, CollectibleType.COLLECTIBLE_D_INFINITY)
function EID:WatchForDice(collectibleType, rng, player)
function EID:WatchForDice(collectibleType, _, player)
if not justDidD or collectibleType == 489 then return end
justDidD = false
local playerID = EID:getPlayerID(player)
@@ -201,7 +201,7 @@ function EID:Teleport2Prediction()
local roomNames = EID:getDescriptionEntry("RoomTypeNames")
-- Return a string for the first uncleared room type that we find
for i,v in ipairs(roomOrder) do
for _,v in ipairs(roomOrder) do
if unclearedTypes[v] then
local descString = (teleport2Icons[v] or EID.RoomTypeToMarkup[v]) .. " " .. roomNames[v]
-- Tall Vertical Main Greed Room exception, because why not, attention to detail
@@ -287,7 +287,7 @@ local specialCards = {[49] = true, [50] = true, [78] = true}
function EID:D1Prediction(rng)
local poss = {}
for i,v in ipairs(Isaac.FindByType(5,-1,-1)) do
for _,v in ipairs(Isaac.FindByType(5,-1,-1)) do
-- Check the blacklist, as well as Rune of Jera in AB+, and empty chests in Rep
if not D1blacklist[v.Variant] and (REPENTANCE or v.Variant ~= 300 or v.SubType ~= 33) and (not REPENTANCE or v:ToPickup():CanReroll()) then
table.insert(poss, v)
+5 -5
View File
@@ -478,14 +478,14 @@ if REPENTANCE then
end
if pickupHistory then
local lastUsedPill = PillEffect.PILLEFFECT_VURP + 1
local i = 1
while (i <= #pickupHistory) do
local entry = pickupHistory[i]
local j = 1
while (j <= #pickupHistory) do
local entry = pickupHistory[j]
if entry[1] == "pill" then
lastUsedPill = entry[3]
break
end
i = i + 1
j = j + 1
end
local tableName = EID:getTableName(descObj.ObjType, descObj.ObjVariant, descObj.ObjSubType)
local name = EID:getPillName(lastUsedPill, tableName == "horsepills")
@@ -660,7 +660,7 @@ end
EID:addDescriptionModifier("EID Afterbirth+", EIDConditionsAB, nil)
-- should this be done differently so that mods can add tab previews? (tab conditions is done last, but would be done before callbacks mods add, maybe tab should be checked in EID:getDescriptionObj
local function TabConditions(descObj)
local function TabConditions(_)
if EID:PlayersActionPressed(EID.Config["BagOfCraftingToggleKey"]) and not EID.inModifierPreview then return true end
EID.TabPreviewID = 0
return false
+11 -11
View File
@@ -250,7 +250,7 @@ if REPENTANCE then
local lastGetItemResult = {nil, nil, nil, nil} -- itemID, Frame, gridIndex, InitSeed
local lastFrameGridChecked = 0
function EID:postGetCollectible(selectedCollectible, itemPoolType, decrease, seed)
function EID:postGetCollectible(selectedCollectible, itemPoolType)
-- Handle Crane Game
if itemPoolType == ItemPoolType.POOL_CRANE_GAME then
for _, crane in ipairs(Isaac.FindByType(6, 16, -1, true, false)) do
@@ -287,7 +287,7 @@ if REPENTANCE then
EID:AddCallback(ModCallbacks.MC_POST_GET_COLLECTIBLE, EID.postGetCollectible)
-- Handle Flip Item spawn
function EID:preRoomEntitySpawn(entityType, variant, subtype, gridIndex, seed)
function EID:preRoomEntitySpawn(entityType, variant, subtype, gridIndex)
flipItemNext = false
if entityType == 6 and variant == 14 then
-- Inner Child pedestal
@@ -369,7 +369,7 @@ if REPENTANCE then
end
-- Watch for a Void absorbing active items
function EID:CheckVoidAbsorbs(collectibleType, rng, player)
function EID:CheckVoidAbsorbs(_, _, player)
local playerID = EID:getPlayerID(player)
EID.absorbedItems[tostring(playerID)] = EID.absorbedItems[tostring(playerID)] or {}
for _,v in ipairs(EID:VoidRoomCheck()) do
@@ -491,7 +491,7 @@ function EID:printDescriptions(useCached)
end
-- Print our cached descriptions
for i,indicator in ipairs(EID.CachedIndicators) do
for _,indicator in ipairs(EID.CachedIndicators) do
EID:renderIndicator(indicator[1], indicator[2])
end
for i,oldDesc in ipairs(EID.previousDescs) do
@@ -922,7 +922,7 @@ function EID:handleHoverHUD()
if EID.Config["ShowCursor"] then
EID.CursorSprite:Render(Vector(mousePos.X / 2, mousePos.Y / 2), nullVector, nullVector)
end
for k, v in pairs(EID.HUDElements) do
for _, v in pairs(EID.HUDElements) do
local hudElement = EID:handleHUDElement(v)
if hudElement.x <= mousePos.X and (hudElement.x + hudElement.width) >= mousePos.X and hudElement.y <= mousePos.Y and (hudElement.y + hudElement.height) >= mousePos.Y then
local result = hudElement.descriptionObj()
@@ -1034,7 +1034,7 @@ end
EID:AddCallback(ModCallbacks.MC_POST_UPDATE, EID.onGameUpdate)
-- Wait until all collectibles spawning this frame have spawned before checking what we need to check about them
function EID:CollectibleSpawnedThisFrame(entity)
function EID:CollectibleSpawnedThisFrame(_)
collSpawned = true
end
EID:AddCallback(ModCallbacks.MC_POST_PICKUP_INIT, EID.CollectibleSpawnedThisFrame, PickupVariant.PICKUP_COLLECTIBLE)
@@ -1055,12 +1055,12 @@ local function attemptPathfind(entity)
pathCheckerEntity = game:Spawn(33, 0, EID.player.Position, nullVector, EID.player, 6969, 4354)
pathCheckerEntity:GetData()["EID_Pathfinder"] = true
pathCheckerEntity.Visible = false
local success = pathCheckerEntity:ToNPC().Pathfinder:HasPathToPos(entity.Position, false)
pathsChecked[entity.InitSeed] = success
local successful = pathCheckerEntity:ToNPC().Pathfinder:HasPathToPos(entity.Position, false)
pathsChecked[entity.InitSeed] = successful
pathCheckerEntity:Remove()
pathCheckerEntity = nil
lastPathfindFrame = EID.GameUpdateCount
return success
return successful
end
local hasShownStartWarning = false
@@ -1158,7 +1158,7 @@ EID.lastDist = 0
EID.OptionChanged = false
EID.bagPlayer = nil
local function onRender(t)
local function onRender()
-- Increases by 60 per second, ignores pauses
EID.GameRenderCount = EID.GameRenderCount + 1
EID.OptionChanged = EID.MCM_OptionChanged
@@ -1567,7 +1567,7 @@ EID:AddCallback(ModCallbacks.MC_USE_ITEM, OnUseD4, CollectibleType.COLLECTIBLE_D
-- Re-init transformation progress and item interactions after using Genesis
if REPENTANCE then
local function OnUseGenesis(_, _, _, player)
local function OnUseGenesis(_, _, _, _)
OnGameStartGeneral()
CheckAllActiveItemProgress()
end