This commit is contained in:
Buurazu authored and GitHub committed 2022-01-14 01:58:22 -05:00
1 parent 9210158b64
commit dce1c7903d
1 file changed
+7 -55
+7 -55
View File
@@ -19,14 +19,6 @@ local logLocation = os.getenv("SYSTEMDRIVE") .. "/Users/" .. os.getenv("USERNAME
local logFound = false
local logCursor = 0
local debugLogLocation = os.getenv("SYSTEMDRIVE") .. "/Users/" .. os.getenv("USERNAME") .. "/Documents/My Games/Binding of Isaac Repentance/tmtrainerlog.txt"
local debugLog = io.open(debugLogLocation, "w+")
-- all possible attributes
--local itemConfigItemAttributes = { "AchievementID", "AddBlackHearts", "AddBombs", "AddCoins", "AddHearts", "AddKeys", "AddMaxHearts", "AddSoulHearts", "CacheFlags", "ChargeType", "ClearEffectsOnRemove", "Costume", "Description", "DevilPrice", "Discharged", "GfxFileName", "Hidden", "ID", "InitCharge", "MaxCharges", "MaxCooldown", "Name", "PassiveCache", "PersistentEffect", "Quality", "ShopPrice", "Special", "Tags", "Type" }
-- the traits here will be checked and listed in this order
local itemConfigItemAttributes = { "AddMaxHearts", "AddHearts", "AddSoulHearts", "AddBlackHearts", "AddBombs", "AddCoins", "AddKeys", "CacheFlags" }
local function entityToName(e, plural)
local localizedNames = EID:getDescriptionEntry("GlitchedItemText")
-- -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
@@ -34,12 +26,10 @@ local function entityToName(e, plural)
plural = plural or false
local name = localizedNames[e] or EID.XMLEntityNames[e] or localizedNames[eWithZero] or EID.XMLEntityNames[eWithZero] or e
--debug print entities with no name yet
if name == e then print("Report this: No name found for " .. e) end
--print out entities with no name yet
if name == e then print("No name found for " .. e .. " (could be modded)")
elseif plural then name = name .. localizedNames["pluralize"] end
--language check?
if plural then name = name .. localizedNames["pluralize"] end
return name
end
@@ -80,8 +70,8 @@ local function parseEffectLine(raw)
replacements[1] = words[6]
elseif effectType == "area_damage" then
replacements[1] = words[6]
-- bug with chain "Then:"! maybe we should just show the 0's since it matters
if words[6] == "0" then printEffect = false end
-- display area_damage 0's because they still need to be done to chain to the next thing
--if words[6] == "0" then printEffect = false end
end
local localizedNames = EID:getDescriptionEntry("GlitchedItemText")
@@ -95,50 +85,12 @@ local function parseEffectLine(raw)
return eidString
end
local function CheckItemConfigItem(id)
-- check for the item ID's ItemConfig attributes (hearts added on pickup, cacheflags affected)
-- unfortunately there doesn't seem to be any way to know exactly how it will affect the cacheflag stats
local localizedNames = EID:getDescriptionEntry("GlitchedItemText")
local config = Isaac.GetItemConfig()
local item = config:GetCollectible(maxNumber - spawnedItems)
local attributes = ""
for k,v in ipairs(itemConfigItemAttributes) do
local attrib = item[v]
if attrib ~= 0 then
if (v == "CacheFlags") then
local flagString = localizedNames["cacheFlagStart"]
if attrib == CacheFlag.CACHE_ALL then
flagString = flagString .. localizedNames[16]
else
for i=0, 13 do
if 2^i & attrib ~= 0 then
flagString = flagString .. localizedNames[i] .. ", "
end
end
flagString = string.sub(flagString, 0, -3) -- remove final comma
end
attributes = attributes .. flagString .. "#"
else
-- the Add Heart attributes count half a heart as 1, so divide the value in half
if string.find(v, "Hearts") then attrib = attrib / 2 end
-- the g flag removes .0 in numbers like 1.0 (caused by the hearts division)
local s = string.format("%.4g",attrib)
if attrib > 0 then s = "+" .. s end
attributes = attributes .. string.gsub(localizedNames[v], "{1}", s)
if attrib ~= 1 and attrib ~= -1 then attributes = attributes .. localizedNames["pluralize"] end
attributes = attributes .. "#"
end
end
end
return attributes
end
--TODO: Add an option for displaying glitched item descriptions check it here
-- Move the item config part to API, it can be used without luadebug
-- bag of crafting hold use to reset bag
local function CheckLogForItems(_)
if (not logFound or game:GetFrameCount() % 5 ~= 0 or not EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_TMTRAINER)) then return end
if not EID.Config["DisplayGlitchedItemInfo"] or not logFound or game:GetFrameCount() % 5 ~= 0 or not EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_TMTRAINER) then return end
local numEffects = 0
local itemScore = 0
@@ -166,7 +118,7 @@ local function CheckLogForItems(_)
-- Glowing Hour Glass type effects seem to cause the game to reload all items, check if our desc is equal to the first one
if (EID:getDescriptionObj(5, 100, maxNumber - 1).Description == eidDesc) then spawnedItems = 1 end
eidDesc = CheckItemConfigItem(maxNumber - spawnedItems) .. eidDesc
eidDesc = EID:CheckGlitchedItemConfig(maxNumber - spawnedItems) .. eidDesc
EID:addCollectible(maxNumber - spawnedItems, eidDesc)
end
end