From 9521913ea9f32d97c55eacf982a05f4a618e1379 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Wed, 19 Jan 2022 05:17:38 -0500 Subject: [PATCH] Move colors, optimize log checks --- eid_tmtrainer.lua | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/eid_tmtrainer.lua b/eid_tmtrainer.lua index eb81f2e1..383af69f 100644 --- a/eid_tmtrainer.lua +++ b/eid_tmtrainer.lua @@ -20,6 +20,18 @@ local logLocation = os.getenv("SYSTEMDRIVE") .. "/Users/" .. os.getenv("USERNAME local logFound = false local logCursor = 0 +local triggerColors = { + chain = "{{ColorSilver}}", + active = "{{ColorLime}}", + pickup_collected = "{{ColorYellow}}", + enemy_kill = "{{ColorRed}}", + damage_taken = "{{ColorRed}}", + entity_spawned = "", + tear_fire = "{{ColorCyan}}", + enemy_hit = "{{ColorEIDError}}", + room_clear = "{{ColorOrange}}", +} + 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 @@ -31,7 +43,7 @@ local function entityToName(e, plural) if name == e then Isaac.DebugString("No name found for " .. e .. " (could be modded)") elseif plural then name = name .. localizedNames["pluralize"] end - return name + return "{{ColorGray}}" .. name .. "{{CR}}" end local function parseEffectLine(raw) @@ -77,7 +89,7 @@ local function parseEffectLine(raw) local localizedNames = EID:getDescriptionEntry("GlitchedItemText") local eidString = "" - if effectTrigger ~= lastEffectTrigger then eidString = eidString .. (localizedNames[effectTrigger] or (effectTrigger .. "#")) end + if effectTrigger ~= lastEffectTrigger then eidString = eidString .. triggerColors[effectTrigger] .. (localizedNames[effectTrigger] or (effectTrigger .. "#")) end if printEffect then eidString = eidString .. (localizedNames[effectType] or fullEffect) .. "#" end for k,v in ipairs(triggerReplacements) do eidString = string.gsub(eidString, "{T" .. k .. "}", v) end for k,v in ipairs(replacements) do eidString = string.gsub(eidString, "{" .. k .. "}", v) end @@ -87,8 +99,11 @@ local function parseEffectLine(raw) end local function CheckLogForItems(_) - if not EID.Config["DisplayGlitchedItemInfo"] or not logFound or game:GetFrameCount() % 5 ~= 0 or not EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_TMTRAINER) then return end - + -- Check log.txt every 5 frames if there's a collectible we haven't read the data for yet + -- (Should work well for Corrupted Data) + if game:GetFrameCount() % 5 ~= 0 or not EID.Config["DisplayGlitchedItemInfo"] or not logFound or + Isaac.GetItemConfig():GetCollectible(maxNumber - spawnedItems - 1) == nil then return end + local numEffects = 0 local itemScore = 0 local eidDesc = ""