From c03b0ddf5210fbd4fe1ac98e83ad38fd4ae0d950 Mon Sep 17 00:00:00 2001 From: LocalIdentity Date: Tue, 2 Jun 2026 23:31:39 +1000 Subject: [PATCH] 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 --- spec/System/TestItemParse_spec.lua | 12 ++++++++++++ src/Classes/ImportTab.lua | 8 ++++++++ src/Classes/Item.lua | 5 ++++- src/Data/Global.lua | 1 + src/Modules/ItemTools.lua | 2 +- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/spec/System/TestItemParse_spec.lua b/spec/System/TestItemParse_spec.lua index 0f928ae665..4bb78fd154 100644 --- a/spec/System/TestItemParse_spec.lua +++ b/spec/System/TestItemParse_spec.lua @@ -329,6 +329,18 @@ describe("TestItemParse", function() assert.truthy(item.explicitModLines[1].custom) end) + it("crafted", function() + local item = new("Item", raw("{crafted}+8 to Strength")) + assert.truthy(item.explicitModLines[1].crafted) + end) + + it("preserves crafted mod lines when rebuilding raw text", function() + local item = new("Item", raw("+8 to Strength")) + item.explicitModLines[1].crafted = true + item:BuildAndParseRaw() + assert.truthy(item.explicitModLines[1].crafted) + end) + it("enchant", function() local item = new("Item", raw("+8 to Strength (enchant)")) assert.are.equals(1, #item.enchantModLines) diff --git a/src/Classes/ImportTab.lua b/src/Classes/ImportTab.lua index c15e5372c4..b94cc52731 100644 --- a/src/Classes/ImportTab.lua +++ b/src/Classes/ImportTab.lua @@ -1240,6 +1240,14 @@ function ImportTabClass:ImportItem(itemData, slotName) end end end + if itemData.craftedMods then + for _, line in ipairs(itemData.craftedMods) do + for line in line:gmatch("[^\n]+") do + local modList, extra = modLib.parseMod(line) + t_insert(item.explicitModLines, { line = line, extra = extra, mods = modList or { }, crafted = true }) + end + end + end if itemData.grantedSkills then for _, grantedSkillInfo in ipairs(itemData.grantedSkills) do diff --git a/src/Classes/Item.lua b/src/Classes/Item.lua index 6c54e83ecc..764d2afc5f 100644 --- a/src/Classes/Item.lua +++ b/src/Classes/Item.lua @@ -64,7 +64,7 @@ local ItemClass = newClass("Item", function(self, raw, rarity, highQuality) end) local lineFlags = { - ["custom"] = true, ["fractured"] = true, ["desecrated"] = true, ["mutated"] = true, ["enchant"] = true, ["implicit"] = true, ["rune"] = true, ["unscalable"] = true + ["custom"] = true, ["crafted"] = true, ["fractured"] = true, ["desecrated"] = true, ["mutated"] = true, ["enchant"] = true, ["implicit"] = true, ["rune"] = true, ["unscalable"] = true } local function baseHasImplicitLine(base, line) @@ -1363,6 +1363,9 @@ function ItemClass:BuildRaw() if modLine.mutated then line = "{mutated}" .. line end + if modLine.crafted then + line = "{crafted}" .. line + end if modLine.unscalable then line = "{unscalable}" .. line end diff --git a/src/Data/Global.lua b/src/Data/Global.lua index 104eaba23c..a78a6d4d74 100644 --- a/src/Data/Global.lua +++ b/src/Data/Global.lua @@ -14,6 +14,7 @@ colorCodes = { GEMINFO = "^x6F9A98", PROPHECY = "^xB54BFF", CURRENCY = "^xAA9E82", + CRAFTED = "^xB8DAF1", ENCHANTED = "^xB8DAF1", CUSTOM = "^x5CF0BB", SOURCE = "^x88FFFF", diff --git a/src/Modules/ItemTools.lua b/src/Modules/ItemTools.lua index ea3bf6dc37..78fd78f493 100644 --- a/src/Modules/ItemTools.lua +++ b/src/Modules/ItemTools.lua @@ -335,7 +335,7 @@ function itemLib.formatModLine(modLine, dbMode) line = line .. " ^1'" .. modLine.extra .. "'" end else - 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 + 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 end return colorCode..line end