Improved stability of "addDescription()" functions with outdated languages
closes #712
This commit is contained in:
1 parent
f6624360e8
commit
1e04b7f91d
2 files changed
+26
No files matched your search
@@ -50,6 +50,7 @@ function EID:addCollectible(id, description, itemName, language)
|
||||
local modName = EID._currentMod
|
||||
-- Glitched Items exception so they don't have a mod name
|
||||
if id > 4294960000 then modName = nil end
|
||||
EID:CreateDescriptionTableIfMissing("custom", language)
|
||||
EID.descriptions[language].custom["5.100." .. id] = {id, itemName, description, modName}
|
||||
end
|
||||
|
||||
@@ -57,6 +58,7 @@ end
|
||||
function EID:addTrinket(id, description, itemName, language)
|
||||
itemName = itemName or nil
|
||||
language = language or "en_us"
|
||||
EID:CreateDescriptionTableIfMissing("custom", language)
|
||||
EID.descriptions[language].custom["5.350." .. id] = {id, itemName, description, EID._currentMod}
|
||||
end
|
||||
|
||||
@@ -64,6 +66,7 @@ end
|
||||
function EID:addCharacterInfo(characterId, description, playerName, language)
|
||||
playerName = playerName or "Modded Character"
|
||||
language = language or "en_us"
|
||||
EID:CreateDescriptionTableIfMissing("CharacterInfo", language)
|
||||
EID.descriptions[language].CharacterInfo[characterId] = {playerName, description}
|
||||
end
|
||||
|
||||
@@ -86,6 +89,7 @@ function EID:addGoldenTrinketMetadata(id, appendText, numbersToMultiply, maxMult
|
||||
|
||||
EID.GoldenTrinketData[id] = {t = numbersToMultiply, mult = maxMultiplier, append = appendText and true}
|
||||
if appendText then
|
||||
EID:CreateDescriptionTableIfMissing("goldenTrinketEffects", language)
|
||||
EID.descriptions[language].goldenTrinketEffects[id] = { appendText[1], appendText[1], appendText[2] or appendText[1] }
|
||||
end
|
||||
end
|
||||
@@ -101,6 +105,7 @@ end
|
||||
function EID:addCard(id, description, itemName, language)
|
||||
itemName = itemName or nil
|
||||
language = language or "en_us"
|
||||
EID:CreateDescriptionTableIfMissing("custom", language)
|
||||
EID.descriptions[language].custom["5.300." .. id] = {id, itemName, description, EID._currentMod}
|
||||
end
|
||||
|
||||
@@ -120,16 +125,20 @@ end
|
||||
function EID:addPill(id, description, itemName, language)
|
||||
itemName = itemName or nil
|
||||
language = language or "en_us"
|
||||
EID:CreateDescriptionTableIfMissing("pills", language)
|
||||
EID:CreateDescriptionTableIfMissing("horsepills", language)
|
||||
EID.descriptions[language].pills[id+1] = {id, itemName, description, EID._currentMod}
|
||||
-- Default the horsepill to the same description as the base pill, for mods that only define the base pill
|
||||
if EID.isRepentance and EID.descriptions[language].horsepills[id+1] == nil then
|
||||
EID.descriptions[language].horsepills[id+1] = {id, itemName, description, EID._currentMod}
|
||||
end
|
||||
end
|
||||
|
||||
function EID:addHorsePill(id, description, itemName, language)
|
||||
if not EID.isRepentance then return end
|
||||
itemName = itemName or nil
|
||||
language = language or "en_us"
|
||||
EID:CreateDescriptionTableIfMissing("horsepills", language)
|
||||
EID.descriptions[language].horsepills[id+1] = {id, itemName, description, EID._currentMod}
|
||||
end
|
||||
|
||||
@@ -148,6 +157,7 @@ end
|
||||
function EID:addBirthright(characterId, description, playerName, language)
|
||||
playerName = playerName or nil
|
||||
language = language or "en_us"
|
||||
EID:CreateDescriptionTableIfMissing("birthright", language)
|
||||
EID.descriptions[language].birthright[characterId + 1] = {playerName, "", description}
|
||||
end
|
||||
|
||||
@@ -251,6 +261,7 @@ function EID:addEntity(id, variant, subtype, entityName, description, language)
|
||||
if id == EntityType.ENTITY_EFFECT then
|
||||
EID.effectList[variant] = true
|
||||
end
|
||||
EID:CreateDescriptionTableIfMissing("custom", language)
|
||||
EID.descriptions[language].custom[id .. "." .. variant .. "." .. subtype] = {
|
||||
subtype,
|
||||
entityName,
|
||||
@@ -2462,3 +2473,13 @@ function EID:ClosestPlayerTo(entity)
|
||||
|
||||
return closestPlayer
|
||||
end
|
||||
|
||||
-- Creates a description table for a given language to prevent outdated languages from breaking EID API functions for mods
|
||||
function EID:CreateDescriptionTableIfMissing(tableName, language)
|
||||
if language and not EID.descriptions[language] then
|
||||
EID.descriptions[language] = {}
|
||||
end
|
||||
if tableName and not EID.descriptions[language][tableName] then
|
||||
EID.descriptions[language][tableName] = {}
|
||||
end
|
||||
end
|
||||
@@ -3,6 +3,7 @@ local modTextsAdded = 0
|
||||
local function newModdedCondition(text, language)
|
||||
if text == nil then return nil end
|
||||
modTextsAdded = modTextsAdded + 1
|
||||
EID:CreateDescriptionTableIfMissing("ConditionalDescs", language)
|
||||
EID.descriptions[language].ConditionalDescs["Modded Conditional " .. modTextsAdded] = text
|
||||
return "Modded Conditional " .. modTextsAdded
|
||||
end
|
||||
@@ -64,6 +65,7 @@ function EID:addToGeneralCondition(ID, locTable, text, numberToDouble, newNumber
|
||||
newNumber = newNumber or numberToDouble * 2
|
||||
text = { numberToDouble, newNumber, text }
|
||||
end
|
||||
EID:CreateDescriptionTableIfMissing(locTable, language)
|
||||
EID.descriptions[language][locTable][ID] = text
|
||||
end
|
||||
|
||||
@@ -110,6 +112,7 @@ function EID:addBFFSCondition(ID, text, numberToDouble, newNumber, language)
|
||||
-- We don't have to add a new condition for collectibles, because they're checked with a "5.100" condition
|
||||
EID:AddItemConditional(ID, 247, EID.CheckForBFFS, {locTable = "BFFSSynergies", replaceColor = "BlinkPink", noFallback = false, uniqueID = "BFFS"})
|
||||
end
|
||||
EID:CreateDescriptionTableIfMissing("BFFSSynergies", language)
|
||||
EID.descriptions[language].BFFSSynergies[ID] = text
|
||||
end
|
||||
|
||||
@@ -129,6 +132,7 @@ function EID:addHiveMindCondition(ID, text, numberToDouble, newNumber, language,
|
||||
-- We don't have to add a new condition for collectibles, because they're checked with a "5.100" condition
|
||||
EID:AddItemConditional(ID, 248, EID.CheckForHiveMind, {locTable = "BFFSSynergies", replaceColor = "BlinkBlue", noFallback = false, uniqueID = "BFFS"})
|
||||
end
|
||||
EID:CreateDescriptionTableIfMissing("BFFSSynergies", language)
|
||||
EID.descriptions[language].BFFSSynergies[ID] = text
|
||||
end
|
||||
|
||||
@@ -169,6 +173,7 @@ local function CopyTable(t1)
|
||||
local newTable = {}; for k, v in pairs(t1) do newTable[k] = v end
|
||||
return newTable
|
||||
end
|
||||
|
||||
-- Every single add conditional function ends up calling this function eventually. This is THE place to define variables every condition MUST have.
|
||||
function EID:AddConditional(IDs, funcText, modText, extraTable)
|
||||
if type(IDs) ~= "table" then IDs = { IDs } end
|
||||
|
||||
Reference in new issue
Block a user