Skip to content

Commit c03b0dd

Browse files
author
LocalIdentity
committed
Fix Crafted mods not importing from items
Add the crafted mod import section to the import tab For some reason we removed the parsing of crafted mods from some of the item mod logic so I added it back along with the colour for crafted mods
1 parent adda267 commit c03b0dd

5 files changed

Lines changed: 26 additions & 2 deletions

File tree

spec/System/TestItemParse_spec.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,18 @@ describe("TestItemParse", function()
329329
assert.truthy(item.explicitModLines[1].custom)
330330
end)
331331

332+
it("crafted", function()
333+
local item = new("Item", raw("{crafted}+8 to Strength"))
334+
assert.truthy(item.explicitModLines[1].crafted)
335+
end)
336+
337+
it("preserves crafted mod lines when rebuilding raw text", function()
338+
local item = new("Item", raw("+8 to Strength"))
339+
item.explicitModLines[1].crafted = true
340+
item:BuildAndParseRaw()
341+
assert.truthy(item.explicitModLines[1].crafted)
342+
end)
343+
332344
it("enchant", function()
333345
local item = new("Item", raw("+8 to Strength (enchant)"))
334346
assert.are.equals(1, #item.enchantModLines)

src/Classes/ImportTab.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,14 @@ function ImportTabClass:ImportItem(itemData, slotName)
12401240
end
12411241
end
12421242
end
1243+
if itemData.craftedMods then
1244+
for _, line in ipairs(itemData.craftedMods) do
1245+
for line in line:gmatch("[^\n]+") do
1246+
local modList, extra = modLib.parseMod(line)
1247+
t_insert(item.explicitModLines, { line = line, extra = extra, mods = modList or { }, crafted = true })
1248+
end
1249+
end
1250+
end
12431251

12441252
if itemData.grantedSkills then
12451253
for _, grantedSkillInfo in ipairs(itemData.grantedSkills) do

src/Classes/Item.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ local ItemClass = newClass("Item", function(self, raw, rarity, highQuality)
6464
end)
6565

6666
local lineFlags = {
67-
["custom"] = true, ["fractured"] = true, ["desecrated"] = true, ["mutated"] = true, ["enchant"] = true, ["implicit"] = true, ["rune"] = true, ["unscalable"] = true
67+
["custom"] = true, ["crafted"] = true, ["fractured"] = true, ["desecrated"] = true, ["mutated"] = true, ["enchant"] = true, ["implicit"] = true, ["rune"] = true, ["unscalable"] = true
6868
}
6969

7070
local function baseHasImplicitLine(base, line)
@@ -1363,6 +1363,9 @@ function ItemClass:BuildRaw()
13631363
if modLine.mutated then
13641364
line = "{mutated}" .. line
13651365
end
1366+
if modLine.crafted then
1367+
line = "{crafted}" .. line
1368+
end
13661369
if modLine.unscalable then
13671370
line = "{unscalable}" .. line
13681371
end

src/Data/Global.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ colorCodes = {
1414
GEMINFO = "^x6F9A98",
1515
PROPHECY = "^xB54BFF",
1616
CURRENCY = "^xAA9E82",
17+
CRAFTED = "^xB8DAF1",
1718
ENCHANTED = "^xB8DAF1",
1819
CUSTOM = "^x5CF0BB",
1920
SOURCE = "^x88FFFF",

src/Modules/ItemTools.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ function itemLib.formatModLine(modLine, dbMode)
335335
line = line .. " ^1'" .. modLine.extra .. "'"
336336
end
337337
else
338-
colorCode = (modLine.enchant and colorCodes.ENCHANTED) or (modLine.fractured and colorCodes.FRACTURED) or (modLine.mutated and colorCodes.MUTATED) or (modLine.custom and (not modLine.desecrated and colorCodes.CUSTOM)) or colorCodes.MAGIC
338+
colorCode = (modLine.crafted and colorCodes.CRAFTED) or (modLine.enchant and colorCodes.ENCHANTED) or (modLine.fractured and colorCodes.FRACTURED) or (modLine.mutated and colorCodes.MUTATED) or (modLine.custom and (not modLine.desecrated and colorCodes.CUSTOM)) or colorCodes.MAGIC
339339
end
340340
return colorCode..line
341341
end

0 commit comments

Comments
 (0)