Added helper function to print errors in console and log
This commit is contained in:
1 parent
9597058ecc
commit
43e9e66bf2
3 files changed
+37
-25
No files matched your search
+20
-8
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user