Overhaul tarot cloth modifier
This commit is contained in:
1 parent
62a65a50cf
commit
eb2718347b
1 file changed
+31
-2
+31
-2
@@ -422,8 +422,37 @@ if EID.isRepentance then
|
||||
local function TarotClothCallback(descObj)
|
||||
local clothBuff = EID:getDescriptionEntry("tarotClothBuffs", descObj.ObjSubType)
|
||||
if clothBuff ~= nil then
|
||||
local iconStr = "#{{Collectible451}} "
|
||||
EID:appendToDescription(descObj, iconStr..clothBuff:gsub("#",iconStr))
|
||||
-- String = append
|
||||
if type(clothBuff) == "string" then
|
||||
local iconStr = "#{{Collectible451}} "
|
||||
EID:appendToDescription(descObj, iconStr..clothBuff:gsub("#",iconStr))
|
||||
-- Table with 1 entry = replace
|
||||
elseif #clothBuff == 1 then
|
||||
descObj.Description = clothBuff[1]
|
||||
-- Table with 2+ entries = find and replace
|
||||
-- Entry 1 is replaced with entry 2, entry 3 is replaced with entry 4, etc.
|
||||
else
|
||||
local pos = 1
|
||||
while pos < #clothBuff do
|
||||
local toFind = clothBuff[pos]
|
||||
local replaceWith = clothBuff[pos+1]
|
||||
|
||||
--"%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 "{{ColorShinyPurple}}" .. replaceWith .. "{{CR}}"
|
||||
end
|
||||
end)
|
||||
-- Basic find+replace for non-numbers
|
||||
else
|
||||
descObj.Description = string.gsub(descObj.Description, tostring(toFind), "{{ColorShinyPurple}}" .. replaceWith .. "{{CR}}", 1)
|
||||
end
|
||||
pos = pos + 2
|
||||
end
|
||||
end
|
||||
end
|
||||
return descObj
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user