More override/overridden conditionals (#692)
* Add layers and unique ID checks * a bunch more overrides * some overridey conditions * shorten spirit sword, some conditions * brimstone mom's knife * reorganize + mom's knife brimstone
This commit is contained in:
1 parent
3b0c1165c0
commit
8ff9f7a262
4 files changed
+154
-103
No files matched your search
@@ -27,11 +27,11 @@ EID:AddItemConditional("5.100", 356, EID.CheckForCarBattery, {locTable = "carBat
|
||||
EID:AddConditional(356, EID.CheckActivesForCarBattery, "No Effect") -- "No effect" text for Car Battery pedestal
|
||||
|
||||
-- BFFS! / Hive Mind
|
||||
EID:AddItemConditional({"5.100","5.350.54","5.350.57"}, 247, EID.CheckForBFFS, {locTable = "BFFSSynergies", replaceColor = "BlinkPink", noFallback = false})
|
||||
EID:AddItemConditional({"5.100","5.350.54","5.350.57"}, 247, EID.CheckForBFFS, {locTable = "BFFSSynergies", replaceColor = "BlinkPink", noFallback = false, uniqueID = "BFFS"})
|
||||
EID:AddConditional(247, EID.CheckFamiliarsForBFFS, "No Effect") -- "No effect" text for BFFS pedestal
|
||||
if EID.isRepentance then
|
||||
EID:AddItemConditional({"5.300.96", "5.350.142", "5.350.176", "5.350.182", "5.350.186"}, 247, EID.CheckForBFFS, {locTable = "BFFSSynergies", replaceColor = "BlinkPink", noFallback = false}) -- BFFS! Repentance soulstone/trinkets
|
||||
EID:AddItemConditional("5.100", 248, EID.CheckForHiveMind, {locTable = "BFFSSynergies", replaceColor = "BlinkBlue", noFallback = false}) -- Hive Mind
|
||||
EID:AddItemConditional("5.100", 248, EID.CheckForHiveMind, {locTable = "BFFSSynergies", replaceColor = "BlinkBlue", noFallback = false, uniqueID = "BFFS"}) -- Hive Mind
|
||||
EID:AddSynergyConditional(247, 248, "No Effect (Familiars)") -- Already having Hive Mind / BFFS!
|
||||
end
|
||||
|
||||
@@ -131,24 +131,60 @@ end
|
||||
|
||||
|
||||
------ OVERRIDES / OVERRIDDEN BY -----
|
||||
-- huge TODO here, a lot of AB+ only ones too
|
||||
-- TODO: Check Azazel and Forgotten's effects with these items, especially Brimstone overrides
|
||||
-- Monstro's Lung might be worthy of this list too?
|
||||
-- Is the layer order correct here? Would I be better off making a new function for adding these overrides that has its own pre-defined layer numbers for the problematic items, to clean up this mess some?
|
||||
EID:AddSynergyConditional({52, 69, 104, 132, 222, 224, 233, 316, 329, 369, 379, 397, 401, 410, 440, 444, 453, 459, 461, 462, 494, 524, 532, 533, 540, }, 168, "Overridden", "Overrides", {layer = 900, checkLayers = true}) -- Epic Fetus
|
||||
EID:AddOneSidedSynergyConditional(168, 118, "Epic Fetus Brimstone", {layer = 900, checkLayers = true})
|
||||
EID:AddOneSidedSynergyConditional(168, 114, "Epic Fetus Mom's Knife", {layer = 900, checkLayers = true})
|
||||
EID:AddOneSidedSynergyConditional(168, 330, "Epic Fetus Soy Milk", {layer = 900, checkLayers = true})
|
||||
|
||||
EID:AddSynergyConditional({69, 132, 222, 316, 369, 379, 410, 440, 453, 459, 461, 494, 524, 532, 533, }, 52, "Overridden", "Overrides", {layer = 800, checkLayers = true}) -- Dr. Fetus
|
||||
EID:AddSynergyConditional(462, 52, "Eye of Belial Dr. Fetus", nil, {layer = 800, checkLayers = true})
|
||||
|
||||
EID:AddSynergyConditional({5, 69, 132, 221, 224, 316, 379, 401, 410, 459, 461, 462, 529, 532, 533, }, 114, "Overridden", "Overrides", {layer = 700, checkLayers = true}) -- Mom's Knife
|
||||
EID:AddOneSidedSynergyConditional(114, 118, "Brimstone Mom's Knife", {layer = 700, checkLayers = true})
|
||||
|
||||
EID:AddSynergyConditional({316, 379, 410, 440, 453, 461, 462, 524, 533, 540, }, 118, "Overridden", "Overrides", {layer = 666, checkLayers = true}) -- Brimstone
|
||||
EID:AddSynergyConditional(118, 149, "Brimstone Ipecac", nil, {layer = 666, checkLayers = true})
|
||||
|
||||
EID:AddSynergyConditional({5, 69, 104, 233, 316, 329, 379, 397, 410, 453, 461, 524, 529, 532, 533, 540, "5.350.26"}, 395, "Overridden", "Overrides", {layer = 600, checkLayers = true}) -- Tech X
|
||||
EID:AddSynergyConditional(149, 395, "Technology Ipecac", nil, {layer = 600, checkLayers = true}) -- Tech X + Ipecac
|
||||
|
||||
EID:AddSynergyConditional({410, 462, 524, 533, 540}, 68, "Overridden", "Overrides", {layer = 400, checkLayers = true}) -- Technology
|
||||
EID:AddSynergyConditional(149, 68, "Technology Ipecac", nil, {layer = 400, checkLayers = true}) -- Technology + Ipecac
|
||||
|
||||
EID:AddSynergyConditional({69, 222, 224, 316, 394, 397, 410, 532}, 329, "Overridden", "Overrides", {layer = 300, checkLayers = true}) -- Ludovico
|
||||
EID:AddSynergyConditional(149, 329, "Ludovico Ipecac", nil, {layer = 300, checkLayers = true}) -- Ludovico + Ipecac
|
||||
|
||||
-- TODO: add azazel to epic fetus list... and what about the brimstone list with him?
|
||||
-- and of course, Mom's Knife, Tech X, Spirit Sword...
|
||||
EID:AddSynergyConditional({52, 69, 104, 222, 224, 233, 316, 329, 369, 379, 397, 401, 410, 440, 444, 453, 459, 461, 462, 494, 524, 532, 533, 540, }, 168, "Overridden", "Overrides") -- Epic Fetus
|
||||
EID:AddSynergyConditional({69, 222, 316, 369, 379, 410, 440, 453, 459, 461, 494, 524, 532, 533, }, 52, "Overridden", "Overrides") -- Dr. Fetus
|
||||
EID:AddSynergyConditional({316, 379, 410, 440, 453, 461, 462, 524, 533, 540, }, 118, "Overridden", "Overrides") -- Brimstone
|
||||
if not EID.isRepentance then
|
||||
EID:AddSynergyConditional({374, 429, }, 168, "Overridden", "Overrides") -- Epic Fetus
|
||||
EID:AddSynergyConditional({374, 401, 429, 444, 461}, 52, "Overridden", "Overrides") -- Dr. Fetus
|
||||
EID:AddSynergyConditional({104, 224, 369, 374, 394, 401, 429, 444, 459, 463, 494, 532, }, 118, "Overridden", "Overrides") -- Brimstone
|
||||
EID:AddSynergyConditional({374, 429, }, 168, "Overridden", "Overrides", {layer = 900, checkLayers = true}) -- Epic Fetus
|
||||
EID:AddSynergyConditional({374, 401, 429, 444, 461}, 52, "Overridden", "Overrides", {layer = 800, checkLayers = true}) -- Dr. Fetus
|
||||
EID:AddSynergyConditional({104, 150, 374, 394, 443, 453, 463, 494, 496, 503, }, 114, "Overridden", "Overrides", {layer = 700, checkLayers = true}) -- Mom's Knife
|
||||
EID:AddSynergyConditional({104, 224, 369, 374, 394, 401, 429, 444, 459, 463, 494, 532, }, 118, "Overridden", "Overrides", {layer = 666, checkLayers = true}) -- Brimstone
|
||||
EID:AddSynergyConditional({55, 87, 150, 221, 374, 394, 401, 429, 443, 444, 463, 494, 496, 503, "5.350.96"}, 395, "Overridden", "Overrides", {layer = 600, checkLayers = true}) -- Tech X
|
||||
EID:AddSynergyConditional({69, 104, 222, 224, 245, 316, 369, 374, 394, 429, 494, }, 68, "Overridden", "Overrides", {layer = 400, checkLayers = true}) -- Technology
|
||||
|
||||
EID:AddSynergyConditional({52, 68, 114, 118, 168, 329, 395}, 69, "Chocolate Milk Overrides", nil, {uniqueID = "choccy"}) -- Chocolate Milk providing fire rate (the override/overridden line happens too)
|
||||
end
|
||||
|
||||
if EID.isRepentance then
|
||||
EID:AddSynergyConditional({168}, 579, "Overridden", "Overrides") -- Spirit Sword
|
||||
EID:AddSynergyConditional({553, 572, 678, "5.350.144"}, 168, "Overridden", "Overrides") -- Epic Fetus
|
||||
EID:AddSynergyConditional({68, 118, 572, 597, 637, "5.350.144"}, 52, "Overridden", "Overrides") -- Dr. Fetus
|
||||
EID:AddSynergyConditional({597}, 118, "Overridden", "Overrides") -- Brimstone
|
||||
EID:AddSynergyConditional({69, 229, 316, 329, 397, 410, 533, 572, 597, }, 678, "Overridden", "Overrides") -- C Section
|
||||
EID:AddOneSidedSynergyConditional(678, 579, "Spirit Sword C Section", {layer = 1001, checkLayers = true}) -- C Section + Spirit Sword
|
||||
EID:AddSynergyConditional({52, 69, 118, 168, 229, 316, 329, 379, 394, 395, 397, 440, 556, 597, }, 579, "Overridden", "Overrides", {layer = 1000, checkLayers = true}) -- Spirit Sword
|
||||
EID:AddOneSidedSynergyConditional(579, 114, "Spirit Sword Mom's Knife", {layer = 1000, checkLayers = true}) -- Spirit Sword + Mom's Knife
|
||||
EID:AddOneSidedSynergyConditional(579, 68, "Spirit Sword Technology", {layer = 1000, checkLayers = true}) -- Spirit Sword + Technology
|
||||
|
||||
EID:AddSynergyConditional({553, 572, 678, "5.350.144"}, 168, "Overridden", "Overrides", {layer = 900, checkLayers = true}) -- Epic Fetus
|
||||
EID:AddOneSidedSynergyConditional(561, 168, "Epic Fetus Soy Milk", {layer = 900, checkLayers = true}) -- Epic Fetus + Almond Milk
|
||||
EID:AddSynergyConditional({69, 229, 316, 329, 397, 410, 533, 572, 597, }, 678, "Overridden", "Overrides", {layer = 850, checkLayers = true}) -- C Section
|
||||
EID:AddSynergyConditional({68, 118, 572, 597, 637, "5.350.144"}, 52, "Overridden", "Overrides", {layer = 800, checkLayers = true}) -- Dr. Fetus
|
||||
EID:AddSynergyConditional({52, 572, 597}, 114, "Overridden", "Overrides", {layer = 700, checkLayers = true}) -- Mom's Knife
|
||||
EID:AddSynergyConditional({597}, 118, "Overridden", "Overrides", {layer = 666, checkLayers = true}) -- Brimstone
|
||||
EID:AddOneSidedSynergyConditional({529, 532}, 118, "Brimstone Pop!", {layer = 666, checkLayers = true}) -- Brimstone + Pop!/Lachryphagy
|
||||
EID:AddSynergyConditional(572, 118, "Eye of the Occult Beam", nil, {layer = 666}) -- Brimstone + Eye of the Occult
|
||||
EID:AddSynergyConditional({572, 597, "5.350.144"}, 395, "Overridden", "Overrides", {layer = 600, checkLayers = true}) -- Tech X
|
||||
EID:AddSynergyConditional({597}, 68, "Overridden", "Overrides", {layer = 400, checkLayers = true}) -- Technology
|
||||
EID:AddSynergyConditional(572, 68, "Eye of the Occult Beam", nil, {layer = 400}) -- Technology + Eye of the Occult
|
||||
|
||||
EID:AddSynergyConditional(330, 561, "Overridden", "Overrides") -- Soy Milk + Almond Milk
|
||||
end
|
||||
@@ -227,10 +263,8 @@ EID:AddItemConditional("5.70.28", 358) -- Wizard pill + The Wiz
|
||||
EID:AddItemConditional(523, 477) -- Moving Box is a passive to Void
|
||||
EID:AddItemConditional({8, 113, 163, 167, 99, 100, 174, 95, 268, 67}, 322, "Mongo Babies") -- Mongo Baby + Copiable familiars
|
||||
if EID.isRepentance then EID:AddItemConditional(608, 322, "Mongo Babies") end
|
||||
EID:AddSynergyConditional(118, 149, "Brimstone Ipecac")
|
||||
EID:AddSynergyConditional(261, 222, "Proptosis Anti-Gravity")
|
||||
EID:AddSynergyConditional(330, 168, "Epic Fetus Soy Milk")
|
||||
EID:AddSynergyConditional(462, 52, "Eye of Belial Dr. Fetus")
|
||||
EID:AddSynergyConditional(394, 69, "Chocolate Milk Marked")
|
||||
|
||||
-- AB+ only misc conditionals
|
||||
if not EID.isRepentance then
|
||||
@@ -241,7 +275,6 @@ end
|
||||
-- Rep only misc conditionals
|
||||
if EID.isRepentance then
|
||||
-- Co-op friendly items
|
||||
-- todo: what items have a cool co-op synergy?
|
||||
EID:AddConditional({45, "5.350.125"}, EID.MultiplePlayerCharacters) -- Yum Heart, Extension Cord
|
||||
EID:AddConditional({"1000.76.0", "1000.76.5"}, EID.MultiplePlayerCharacters) -- Dice Room 1 and 6
|
||||
|
||||
@@ -254,8 +287,6 @@ if EID.isRepentance then
|
||||
EID:AddPlayerConditional(596, 27, "Ice Tears") -- Uranus + Tainted Samson
|
||||
EID:AddSynergyConditional(495, 616, "Both Peppers") -- Ghost Pepper + Bird's Eye
|
||||
EID:AddSynergyConditional(726, {408, 646, 293, 679, 275, 399, 680, 441, 49, 533}, "Hemoptysis") -- Hemoptysis + Brimstone effects
|
||||
EID:AddOneSidedSynergyConditional({529, 532}, 118, "Brimstone Pop!") -- Brimstone + Pop!/Lachryphagy
|
||||
EID:AddSynergyConditional(561, 168, "Epic Fetus Soy Milk") -- Epic Fetus + Almond Milk
|
||||
|
||||
-- eye drops + chargeable passives like brimstone could go here but there's a lot of them
|
||||
EID:AddPlayerConditional(600, {2, 7, 13, 16}) -- Eye Drops + Cain, Azazel, Lilith, Forgotten
|
||||
|
||||
@@ -78,7 +78,7 @@ function EID:addBFFSCondition(ID, text, numberToDouble, newNumber, language)
|
||||
if type(ID) ~= "string" then ID = "5.100." .. ID
|
||||
else
|
||||
-- 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})
|
||||
EID:AddItemConditional(ID, 247, EID.CheckForBFFS, {locTable = "BFFSSynergies", replaceColor = "BlinkPink", noFallback = false, uniqueID = "BFFS"})
|
||||
end
|
||||
EID.descriptions[language].BFFSSynergies[ID] = text
|
||||
end
|
||||
@@ -97,7 +97,7 @@ function EID:addHiveMindCondition(ID, text, numberToDouble, newNumber, language,
|
||||
if type(ID) ~= "string" then ID = "5.100." .. ID
|
||||
else
|
||||
-- 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})
|
||||
EID:AddItemConditional(ID, 248, EID.CheckForHiveMind, {locTable = "BFFSSynergies", replaceColor = "BlinkBlue", noFallback = false, uniqueID = "BFFS"})
|
||||
end
|
||||
EID.descriptions[language].BFFSSynergies[ID] = text
|
||||
end
|
||||
@@ -129,18 +129,21 @@ end
|
||||
bulletpoint: Appended lines will begin with this bulletpoint
|
||||
noFallback: Don't fallback to English if this isn't localized; by default, conditionals don't fallback, to avoid printing English text in unupdated languages
|
||||
usePedestalName: If true, display the pedestal item's name in place of {1}
|
||||
|
||||
Argument 5 (very optional): The position in the table to insert this new condition, in case mods want to insert modifiers before our base ones
|
||||
layer: A number used in determining the order that conditionals should be checked in, default -1
|
||||
checkLayers: If true, don't print this condition if a higher layer condition was applied already
|
||||
uniqueID: Only one conditional with the given unique ID will be printed
|
||||
]]
|
||||
local function CopyTable(t1)
|
||||
local newTable = {}; for k, v in pairs(t1) do newTable[k] = v end
|
||||
return newTable
|
||||
end
|
||||
function EID:AddConditional(IDs, funcText, modText, extraTable, insertPoint)
|
||||
-- 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
|
||||
if modText == "" then modText = nil end
|
||||
extraTable = extraTable or {}
|
||||
if extraTable.noFallback == nil then extraTable.noFallback = true end
|
||||
extraTable.layer = extraTable.layer or -1
|
||||
for _, id in ipairs(IDs) do
|
||||
if type(id) ~= "string" then id = "5.100." .. id end
|
||||
EID.DescriptionConditions[id] = EID.DescriptionConditions[id] or {}
|
||||
@@ -151,12 +154,7 @@ function EID:AddConditional(IDs, funcText, modText, extraTable, insertPoint)
|
||||
if newTable.usePedestalName then
|
||||
newTable.variableText = "{{NameOnly" .. id .. "}}"
|
||||
end
|
||||
|
||||
if insertPoint then
|
||||
table.insert(EID.DescriptionConditions[id], insertPoint, newTable)
|
||||
else
|
||||
table.insert(EID.DescriptionConditions[id], newTable)
|
||||
end
|
||||
table.insert(EID.DescriptionConditions[id], newTable)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -425,88 +423,97 @@ function EID:applyConditionals(descObj)
|
||||
local adjustedSubtype = EID:getAdjustedSubtype(descObj.ObjType, descObj.ObjVariant, descObj.ObjSubType)
|
||||
local typeVar = descObj.ObjType.."."..descObj.ObjVariant -- for general conditions (Tarot Cloth, Book of Virtues)
|
||||
local typeVarSub = descObj.ObjType.."."..descObj.ObjVariant.."."..adjustedSubtype -- for specific conditions
|
||||
local highestLayer = -999
|
||||
local printedDescs = {}
|
||||
|
||||
-- Combine specific+generic conditions into one table (in that order)
|
||||
local conds = {}
|
||||
if EID.DescriptionConditions[typeVarSub] then TableConcat(conds, EID.DescriptionConditions[typeVarSub]) end
|
||||
if EID.DescriptionConditions[typeVar] then TableConcat(conds, EID.DescriptionConditions[typeVar]) end
|
||||
table.sort(conds, function(a, b) return a.layer > b.layer end)
|
||||
-- Check every condition we need to check for this item
|
||||
for _, cond in ipairs(conds) do
|
||||
-- Search for the localization string; "S" (for generals) or "T.V.S" or "T.V.S (Modifier)" or "Modifier"
|
||||
local locTable = cond.locTable or "ConditionalDescs"
|
||||
local text = nil
|
||||
local modifierText = type(cond.modifierText) == "function" and cond.modifierText(EID, descObj) or cond.modifierText
|
||||
|
||||
-- Find our string in the base localization table
|
||||
if cond.noTable then
|
||||
text = EID:getDescriptionEntry(modifierText, nil, cond.noFallback)
|
||||
-- Find our string as either "Type.Var.Sub (Mod Text)" or "Mod Text"
|
||||
elseif modifierText then
|
||||
text = EID:getDescriptionEntry(locTable, typeVarSub .. " (" .. modifierText .. ")", cond.noFallback)
|
||||
if text == nil then text = EID:getDescriptionEntry(locTable, modifierText, cond.noFallback) end
|
||||
-- Find our string as either "Type.Var.Sub" or just the Subtype
|
||||
else
|
||||
text = EID:getDescriptionEntry(locTable, typeVarSub, cond.noFallback)
|
||||
if text == nil then text = EID:getDescriptionEntry(locTable, descObj.ObjSubType, cond.noFallback) end
|
||||
end
|
||||
if not cond.checkLayers or highestLayer <= cond.layer then
|
||||
local result = cond.func(EID, descObj)
|
||||
if result then
|
||||
-- Search for the localization string; "S" (for generals) or "T.V.S" or "T.V.S (Modifier)" or "Modifier"
|
||||
local locTable = cond.locTable or "ConditionalDescs"
|
||||
local text = nil
|
||||
local modifierText = type(cond.modifierText) == "function" and cond.modifierText(EID, descObj) or cond.modifierText
|
||||
|
||||
-- Find our string in the base localization table
|
||||
if cond.noTable then
|
||||
text = EID:getDescriptionEntry(modifierText, nil, cond.noFallback)
|
||||
-- Find our string as either "Type.Var.Sub (Mod Text)" or "Mod Text"
|
||||
elseif modifierText then
|
||||
text = EID:getDescriptionEntry(locTable, typeVarSub .. " (" .. modifierText .. ")", cond.noFallback)
|
||||
if text == nil then text = EID:getDescriptionEntry(locTable, modifierText, cond.noFallback) end
|
||||
-- Find our string as either "Type.Var.Sub" or just the Subtype
|
||||
else
|
||||
text = EID:getDescriptionEntry(locTable, typeVarSub, cond.noFallback)
|
||||
if text == nil then text = EID:getDescriptionEntry(locTable, descObj.ObjSubType, cond.noFallback) end
|
||||
end
|
||||
|
||||
-- If we find the localization string for this condition, and it passes the test, modify the description text
|
||||
local result = cond.func(EID, descObj)
|
||||
if text ~= nil and result then
|
||||
local variableText, bulletpoint
|
||||
-- If the condition returned a value, use that value
|
||||
if result ~= true then
|
||||
-- For the time being, we assume the result was a collectible number (will support more soon)
|
||||
variableText = "{{NameOnlyC"..result.."}}"
|
||||
bulletpoint = "Collectible"..result
|
||||
else
|
||||
variableText = type(cond.variableText) == "function" and cond.variableText(EID, descObj) or cond.variableText
|
||||
bulletpoint = cond.bulletpoint
|
||||
end
|
||||
|
||||
-- String = append
|
||||
if type(text) == "string" then
|
||||
text = EID:ReplaceVariableStr(text, 1, variableText)
|
||||
local iconStr = "#"
|
||||
if bulletpoint then iconStr = iconStr .. "{{" .. bulletpoint .. "}} " end
|
||||
if cond.lineColor then iconStr = iconStr .. "{{" .. cond.lineColor .. "}}" end
|
||||
EID:appendToDescription(descObj, iconStr .. text:gsub("#", iconStr))
|
||||
|
||||
-- Table with 1 entry = replace
|
||||
elseif #text == 1 then
|
||||
descObj.Description = EID:ReplaceVariableStr(text[1], 1, variableText)
|
||||
|
||||
-- Table with 2+ entries = find and replace pairs
|
||||
-- Entry 1 is replaced with entry 2, entry 3 is replaced with entry 4, etc.
|
||||
-- If there's an odd number of entries, the last one is appended
|
||||
else
|
||||
local pos = 1
|
||||
while pos <= #text do
|
||||
local toFind = text[pos]
|
||||
if text[pos + 1] then
|
||||
local replaceWith = EID:ReplaceVariableStr(text[pos + 1], 1, variableText)
|
||||
if cond.replaceColor then replaceWith = "{{" .. cond.replaceColor .. "}}" .. replaceWith .. "{{CR}}" end
|
||||
--"%d*%.?%d+" will grab every number group (1, 10, 0.5), this will allow us to not replace the "1" in "10" erroneously
|
||||
if (type(toFind) == "number") then
|
||||
local count = 0
|
||||
descObj.Description = string.gsub(descObj.Description, "%d*%.?%d+", function(s)
|
||||
if (s == tostring(toFind) and count == 0) then
|
||||
count = count + 1
|
||||
return replaceWith
|
||||
end
|
||||
end)
|
||||
-- Basic find+replace for non-numbers
|
||||
else
|
||||
descObj.Description = replace(descObj.Description, tostring(toFind), replaceWith, 1)
|
||||
end
|
||||
-- If we find the localization string for this condition, it passed the condition's test, and the layer is ok, modify the description text
|
||||
if text ~= nil and (not cond.uniqueID or printedDescs[cond.uniqueID] == nil) then
|
||||
if cond.layer > highestLayer then highestLayer = cond.layer end
|
||||
if cond.uniqueID then printedDescs[cond.uniqueID] = true end
|
||||
local variableText, bulletpoint
|
||||
-- If the condition returned a value, use that value
|
||||
if result ~= true then
|
||||
-- For the time being, we assume the result was a collectible number (will support more soon)
|
||||
variableText = "{{NameOnlyC"..result.."}}"
|
||||
bulletpoint = "Collectible"..result
|
||||
else
|
||||
toFind = EID:ReplaceVariableStr(toFind, 1, variableText)
|
||||
variableText = type(cond.variableText) == "function" and cond.variableText(EID, descObj) or cond.variableText
|
||||
bulletpoint = cond.bulletpoint
|
||||
end
|
||||
|
||||
-- String = append
|
||||
if type(text) == "string" then
|
||||
text = EID:ReplaceVariableStr(text, 1, variableText)
|
||||
local iconStr = "#"
|
||||
if bulletpoint then iconStr = iconStr .. "{{" .. bulletpoint .. "}} " end
|
||||
if cond.lineColor then iconStr = iconStr .. "{{" .. cond.lineColor .. "}}" end
|
||||
EID:appendToDescription(descObj, iconStr .. toFind:gsub("#", iconStr))
|
||||
EID:appendToDescription(descObj, iconStr .. text:gsub("#", iconStr))
|
||||
|
||||
-- Table with 1 entry = replace
|
||||
elseif #text == 1 then
|
||||
descObj.Description = EID:ReplaceVariableStr(text[1], 1, variableText)
|
||||
|
||||
-- Table with 2+ entries = find and replace pairs
|
||||
-- Entry 1 is replaced with entry 2, entry 3 is replaced with entry 4, etc.
|
||||
-- If there's an odd number of entries, the last one is appended
|
||||
else
|
||||
local pos = 1
|
||||
while pos <= #text do
|
||||
local toFind = text[pos]
|
||||
if text[pos + 1] then
|
||||
local replaceWith = EID:ReplaceVariableStr(text[pos + 1], 1, variableText)
|
||||
if cond.replaceColor then replaceWith = "{{" .. cond.replaceColor .. "}}" .. replaceWith .. "{{CR}}" end
|
||||
--"%d*%.?%d+" will grab every number group (1, 10, 0.5), this will allow us to not replace the "1" in "10" erroneously
|
||||
if (type(toFind) == "number") then
|
||||
local count = 0
|
||||
descObj.Description = string.gsub(descObj.Description, "%d*%.?%d+", function(s)
|
||||
if (s == tostring(toFind) and count == 0) then
|
||||
count = count + 1
|
||||
return replaceWith
|
||||
end
|
||||
end)
|
||||
-- Basic find+replace for non-numbers
|
||||
else
|
||||
descObj.Description = replace(descObj.Description, tostring(toFind), replaceWith, 1)
|
||||
end
|
||||
else
|
||||
toFind = EID:ReplaceVariableStr(toFind, 1, variableText)
|
||||
local iconStr = "#"
|
||||
if bulletpoint then iconStr = iconStr .. "{{" .. bulletpoint .. "}} " end
|
||||
if cond.lineColor then iconStr = iconStr .. "{{" .. cond.lineColor .. "}}" end
|
||||
EID:appendToDescription(descObj, iconStr .. toFind:gsub("#", iconStr))
|
||||
end
|
||||
pos = pos + 2
|
||||
end
|
||||
end
|
||||
pos = pos + 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user