From 9d9c3bcf92dd8d934c3727ec342fb63479437dc5 Mon Sep 17 00:00:00 2001 From: Adrian Klingen Date: Sat, 15 Jun 2024 17:45:23 +0200 Subject: [PATCH 1/4] Fill previous gems --- ExportStructures/ItemSpec.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ExportStructures/ItemSpec.lua b/ExportStructures/ItemSpec.lua index 206ca03..cd3b10f 100644 --- a/ExportStructures/ItemSpec.lua +++ b/ExportStructures/ItemSpec.lua @@ -54,6 +54,15 @@ function ItemSpecMeta:FillFromItemLink(itemLink) self.id = tonumber(itemId) self.enchant = tonumber(enchantId) if self._structure.gems then + if not isGem(gemId1) and isGem(gemId2) or isGem(gemId3) or isGem(gemId4) then + gemId1 = 0 + end + if not isGem(gemId2) and isGem(gemId3) or isGem(gemId4) then + gemId2 = 0 + end + if not isGem(gemId3) and isGem(gemId4) then + gemId3 = 0 + end self.gems = { tonumber(gemId1), tonumber(gemId2), tonumber(gemId3), tonumber(gemId4) } end if self._structure.random_suffix then @@ -61,6 +70,13 @@ function ItemSpecMeta:FillFromItemLink(itemLink) end end +---Returns if gemID string is a gem. +---@param gemId string +function isGem(gemId) + if gemId == '' then return false end + return true +end + ---Set rune spell from an item in a slot, if item has a rune engraved. ---@param slotId integer ---@param bagId integer|nil If not nil check bag items instead of equipped items. From 5af6c45e6b05ce5b9b5e29feae5d44e4492f3fd7 Mon Sep 17 00:00:00 2001 From: Adrian Klingen Date: Sat, 15 Jun 2024 18:03:53 +0200 Subject: [PATCH 2/4] Change to loop --- ExportStructures/ItemSpec.lua | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ExportStructures/ItemSpec.lua b/ExportStructures/ItemSpec.lua index cd3b10f..cce20b4 100644 --- a/ExportStructures/ItemSpec.lua +++ b/ExportStructures/ItemSpec.lua @@ -54,16 +54,14 @@ function ItemSpecMeta:FillFromItemLink(itemLink) self.id = tonumber(itemId) self.enchant = tonumber(enchantId) if self._structure.gems then - if not isGem(gemId1) and isGem(gemId2) or isGem(gemId3) or isGem(gemId4) then - gemId1 = 0 - end - if not isGem(gemId2) and isGem(gemId3) or isGem(gemId4) then - gemId2 = 0 - end - if not isGem(gemId3) and isGem(gemId4) then - gemId3 = 0 - end self.gems = { tonumber(gemId1), tonumber(gemId2), tonumber(gemId3), tonumber(gemId4) } + + -- Loop over all filled gems and make sure to backwards fill emppy slots with 0. + for i = 1, #self.gems do + if i > 1 and self.gems[i] and not self.gems[i - 1] then + self.gems[i - 1] = 0 + end + end end if self._structure.random_suffix then self.random_suffix = tonumber(suffixId) From 3e978bfcb6a230b6f33ad989d83f0a7d7c80795a Mon Sep 17 00:00:00 2001 From: Adrian Klingen Date: Sat, 15 Jun 2024 18:05:44 +0200 Subject: [PATCH 3/4] remove isGem function --- ExportStructures/ItemSpec.lua | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ExportStructures/ItemSpec.lua b/ExportStructures/ItemSpec.lua index cce20b4..50cf7d8 100644 --- a/ExportStructures/ItemSpec.lua +++ b/ExportStructures/ItemSpec.lua @@ -68,13 +68,6 @@ function ItemSpecMeta:FillFromItemLink(itemLink) end end ----Returns if gemID string is a gem. ----@param gemId string -function isGem(gemId) - if gemId == '' then return false end - return true -end - ---Set rune spell from an item in a slot, if item has a rune engraved. ---@param slotId integer ---@param bagId integer|nil If not nil check bag items instead of equipped items. From 5b10918421f3a8fe5a4d4e28c8f1c89144b037af Mon Sep 17 00:00:00 2001 From: Adrian Klingen Date: Sat, 15 Jun 2024 18:06:46 +0200 Subject: [PATCH 4/4] Fix comment typo --- ExportStructures/ItemSpec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExportStructures/ItemSpec.lua b/ExportStructures/ItemSpec.lua index 50cf7d8..2507022 100644 --- a/ExportStructures/ItemSpec.lua +++ b/ExportStructures/ItemSpec.lua @@ -56,7 +56,7 @@ function ItemSpecMeta:FillFromItemLink(itemLink) if self._structure.gems then self.gems = { tonumber(gemId1), tonumber(gemId2), tonumber(gemId3), tonumber(gemId4) } - -- Loop over all filled gems and make sure to backwards fill emppy slots with 0. + -- Loop over all filled gems and make sure to backwards fill empty (nil) gem slots with 0. for i = 1, #self.gems do if i > 1 and self.gems[i] and not self.gems[i - 1] then self.gems[i - 1] = 0