diff --git a/features/eid_api.lua b/features/eid_api.lua index f5398886..e9972084 100644 --- a/features/eid_api.lua +++ b/features/eid_api.lua @@ -142,7 +142,7 @@ function EID:addCollectible(id, description, itemName, language) itemName = itemName or nil language = language or "en_us" if id == -1 then - print("EID Error: Trying to add collectible description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") + EID:WriteErrorMsg("Trying to add collectible description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") return end local modName = EID._currentMod @@ -161,7 +161,7 @@ function EID:addTrinket(id, description, itemName, language) itemName = itemName or nil language = language or "en_us" if id == -1 then - print("EID Error: Trying to add trinket description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") + EID:WriteErrorMsg("Trying to add trinket description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") return end EID:CreateDescriptionTableIfMissing("custom", language) @@ -177,7 +177,7 @@ function EID:addCharacterInfo(characterId, description, playerName, language) playerName = playerName or "Modded Character" language = language or "en_us" if characterId == -1 then - print("EID Error: Trying to add character description to id = -1, which is not allowed! (Name: "..tostring(playerName).."; Description: "..tostring(description)..")") + EID:WriteErrorMsg("Trying to add character description to id = -1, which is not allowed! (Name: "..tostring(playerName).."; Description: "..tostring(description)..")") return end EID:CreateDescriptionTableIfMissing("CharacterInfo", language) @@ -229,7 +229,7 @@ function EID:addCard(id, description, itemName, language) itemName = itemName or nil language = language or "en_us" if id == -1 then - print("EID Error: Trying to add card description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") + EID:WriteErrorMsg("Trying to add card description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") return end EID:CreateDescriptionTableIfMissing("custom", language) @@ -259,7 +259,7 @@ function EID:addPill(id, description, itemName, language) itemName = itemName or nil language = language or "en_us" if id == -1 then - print("EID Error: Trying to add pill description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") + EID:WriteErrorMsg("Trying to add pill description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") return end EID:CreateDescriptionTableIfMissing("pills", language) @@ -281,7 +281,7 @@ function EID:addHorsePill(id, description, itemName, language) itemName = itemName or nil language = language or "en_us" if id == -1 then - print("EID Error: Trying to add horsepill description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") + EID:WriteErrorMsg("Trying to add horsepill description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") return end EID:CreateDescriptionTableIfMissing("horsepills", language) @@ -308,7 +308,7 @@ function EID:addBirthright(characterId, description, playerName, language) playerName = playerName or nil language = language or "en_us" if characterId == -1 then - print("EID Error: Trying to add Birthright description to id = -1, which is not allowed! (Name: "..tostring(characterId).."; Description: "..tostring(description)..")") + EID:WriteErrorMsg("Trying to add Birthright description to id = -1, which is not allowed! (Name: "..tostring(characterId).."; Description: "..tostring(description)..")") return end EID:CreateDescriptionTableIfMissing("birthright", language) @@ -557,7 +557,7 @@ function EID:loadFont(fontFileName) EID.font:SetMissingCharacter(2) ---@diagnostic enable if not EID.font:IsLoaded() then - Isaac.DebugString("EID - ERROR: Could not load font from '" .. EID.modPath .. "resources/font/default.fnt" .. "'") + EID:WriteErrorMsg("Could not load font from '" .. EID.modPath .. "resources/font/default.fnt" .. "'") return false end return true @@ -3179,3 +3179,15 @@ function EID:HasPathToPosition(startPos, endPos) -- return true if it has a path return pathfinderObj:GetPath() ~= nil end + +---Prints a message in both the console and the Log file, to make important messages from EID stand out everywhere +---@param str string +function EID:WriteDebugMsg(str) + print(str) + Isaac.DebugString(str) +end +---Prints an error message in both the console and the Log file, to make important messages from EID stand out everywhere +---@param str string +function EID:WriteErrorMsg(str) + EID:WriteDebugMsg("EID ERROR: " .. str) +end \ No newline at end of file diff --git a/features/eid_debugging.lua b/features/eid_debugging.lua index cc6d79ef..c29bc123 100644 --- a/features/eid_debugging.lua +++ b/features/eid_debugging.lua @@ -17,7 +17,7 @@ function EID:countEntries(t) end EID:countEntries(EID.descriptions["en_us"]) local enUSEntries = count -print("en_us entries: "..enUSEntries) +EID:WriteDebugMsg("en_us entries: "..enUSEntries) local maxChecklimit = {["tarotClothBuffs"] = 2} @@ -34,7 +34,7 @@ local ignoreNodesWithName = {["fonts"] = true} for _, lang in ipairs(languageFilesToCheck) do - print("Now checking integrity of languagefile: " .. lang) + EID:WriteDebugMsg("Now checking integrity of languagefile: " .. lang) -- Generic function to compare two tables function EID:compareTables(table1, table2, prevKey, progress) local checkLimit = EID:getMaxCheckLimit(prevKey) @@ -44,10 +44,10 @@ for _, lang in ipairs(languageFilesToCheck) do if not (ignoreNodesWithName[k] or checkLimit < 0) then -- only evaluate nodes that are not listed in this table if not table2[k] then - print(" Table '" .. prevKey .. "' does not contain key: " .. k) + EID:WriteDebugMsg(" Table '" .. prevKey .. "' does not contain key: " .. k) progress[2] = progress[2] + 1 elseif type(table2[k]) ~= type(table1[k]) then - -- print("Type mismatch in table '" .. prevKey .. "', key: " .. k) + -- EID:WriteDebugMsg("Type mismatch in table '" .. prevKey .. "', key: " .. k) progress[2] = progress[2] + 1 elseif type(table2[k]) == "table" then EID:compareTables(table1[k], table2[k], prevKey.."->"..k, progress) @@ -59,7 +59,7 @@ for _, lang in ipairs(languageFilesToCheck) do local filteredSpriteText, spriteTable = EID:filterIconMarkup(textPart[1]) if string.find(filteredSpriteText, "{{") or string.find(filteredSpriteText, "}}") then - print(" Table '" .. + EID:WriteDebugMsg(" Table '" .. prevKey .. "' entry '" .. k .. "' does contain a broken markup object: '" .. table2[k]) progress[1] = progress[1] - 2 progress[2] = progress[2] + 1 @@ -67,7 +67,7 @@ for _, lang in ipairs(languageFilesToCheck) do else for _, sprite in ipairs(spriteTable) do if sprite[1][1] == "ERROR" then - print(" Table '" .. + EID:WriteDebugMsg(" Table '" .. prevKey .. "' entry '" .. k .. "' does contain a bad icon markup in string: '" .. table2[k]) progress[1] = progress[1] - 2 @@ -86,8 +86,8 @@ for _, lang in ipairs(languageFilesToCheck) do EID:compareTables(EID.descriptions["en_us"], EID.descriptions[lang], lang, progress) local errors = (enUSEntries - progress[1])-progress[2] - print("Errors found: "..errors .." / "..enUSEntries) - print("Translation progress: "..((enUSEntries-errors)/enUSEntries*100).."%") + EID:WriteDebugMsg("Errors found: "..errors .." / "..enUSEntries) + EID:WriteDebugMsg("Translation progress: "..((enUSEntries-errors)/enUSEntries*100).."%") end diff --git a/main.lua b/main.lua index 943d80d6..606198f1 100644 --- a/main.lua +++ b/main.lua @@ -1,4 +1,4 @@ -if EID and EID.Name then print("Error: Two instances of EID found! Please uninstall one of them!") return end -- If EID is already loaded, warn the user and dont load the second one. +if EID and EID.Name then print("EID Error: Two instances of EID found! Please uninstall one of them!") return end -- If EID is already loaded, warn the user and dont load the second one. EID = RegisterMod("External Item Descriptions", 1) -- important variables EID.GameVersion = "ab+" @@ -129,7 +129,7 @@ if EID.isRepentance then for _,lang in ipairs(EID.Languages) do local wasSuccessful, err = pcall(require,"descriptions."..EID.GameVersion.."."..lang) if not wasSuccessful and not string.find(err, "not found") then - Isaac.ConsoleOutput("Load rep "..lang.." failed: "..tostring(err)) + EID:WriteErrorMsg("Load rep "..lang.." failed: "..tostring(err)) end end local _, _ = pcall(require,"descriptions."..EID.GameVersion..".transformations") @@ -142,7 +142,7 @@ if EID.isRepentance then for _,lang in ipairs(EID.Languages) do local wasSuccessful, err = pcall(require,"descriptions."..EID.GameVersion.."."..lang) if not wasSuccessful and not string.find(err, "not found") then - Isaac.ConsoleOutput("Load rep+ "..lang.." failed: "..tostring(err)) + EID:WriteErrorMsg("Load rep+ "..lang.." failed: "..tostring(err)) end end local _, _ = pcall(require,"descriptions."..EID.GameVersion..".transformations") @@ -182,16 +182,16 @@ if not success then if EID.isRepentance then success = EID:loadFont("../mods/"..modfolder.."/resources/font/eid_"..fontFile..".fnt") if not success then - Isaac.ConsoleOutput("EID WAS NOT ABLE TO LOAD THE FONT!!!!!!!! Please contact the mod creator!\n") - Isaac.ConsoleOutput("File not found (absolute path): "..EID.modPath .. "resources/font/eid_"..fontFile..".fnt\n") - Isaac.ConsoleOutput("File not found (relative path): ../mods/"..modfolder.."/resources/font/eid_"..fontFile..".fnt") + EID:WriteErrorMsg("EID WAS NOT ABLE TO LOAD THE FONT!!!!!!!! Please contact the mod creator!\n") + EID:WriteErrorMsg("File not found (absolute path): "..EID.modPath .. "resources/font/eid_"..fontFile..".fnt\n") + EID:WriteErrorMsg("File not found (relative path): ../mods/"..modfolder.."/resources/font/eid_"..fontFile..".fnt") return else EID.modPath = "../mods/"..modfolder.."/" end else - Isaac.ConsoleOutput("EID WAS NOT ABLE TO LOAD THE FONT!!!!!!!! Please contact the mod creator!\n") - Isaac.ConsoleOutput("File does not exist: "..EID.modPath .. "resources/font/eid_"..fontFile..".fnt") + EID:WriteErrorMsg("EID WAS NOT ABLE TO LOAD THE FONT!!!!!!!! Please contact the mod creator!\n") + EID:WriteErrorMsg("File does not exist: "..EID.modPath .. "resources/font/eid_"..fontFile..".fnt") return end end @@ -1871,7 +1871,7 @@ function EID:OnGameStart(isSave) local isDefaultConfig = true for key, value in pairs(EID.Config) do if type(value) ~= type(EID.DefaultConfig[key]) and not configIgnoreList[key] then - print("EID Warning! : Config value '"..key.."' has wrong data-type. Resetting it to default...") + EID:WriteDebugMsg("EID Warning: Config value '"..key.."' has wrong data-type. Resetting it to default...") EID.Config[key] = EID.DefaultConfig[key] end if EID.DefaultConfig[key] ~= value then