From 8938c2cc5f5d81a3fbc3299e6cb942feadd50f2b Mon Sep 17 00:00:00 2001 From: Federico Bellia Date: Sat, 6 Jul 2019 15:56:12 +0200 Subject: [PATCH 1/2] Changes crafted modifiers sort order Crafted item modifiers where not sorted according to any specific criteria. Now they are sorted in alphabetical order, excluding any initial magnitude prefix: Ex: "+10% ham" comes after "Gummybears" --- Classes/ItemsTab.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Classes/ItemsTab.lua b/Classes/ItemsTab.lua index c39009f25..f49e0e136 100644 --- a/Classes/ItemsTab.lua +++ b/Classes/ItemsTab.lua @@ -1568,6 +1568,23 @@ function ItemsTabClass:AddCustomModifierToDisplayItem() }) end end + + -- Sorts modifiers by label + -- Ignores the initial magnitude part + -- Ex: "+10% ham" comes after "Gummybears" + table.sort(modList, function comparator(l, r) + local l_first_letter_index = string.find(l.label, "[%u%l]") + local r_first_letter_index = string.find(r.label, "[%u%l]") + + local lthunk = string.lower(string.sub(l.label, l_first_letter_index)) + local rthunk = string.lower(string.sub(r.label, r_first_letter_index)) + + if lthunk < rthunk then + return true + else + return false + end + end) elseif sourceId == "ESSENCE" then for _, essence in pairs(self.build.data.essences) do local modId = essence.mods[self.displayItem.type] From 4791311a6c9e2e547e1ce8d28221695c3d558c06 Mon Sep 17 00:00:00 2001 From: Federico Bellia Date: Sat, 6 Jul 2019 16:03:20 +0200 Subject: [PATCH 2/2] Fixes whitespace --- Classes/ItemsTab.lua | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Classes/ItemsTab.lua b/Classes/ItemsTab.lua index f49e0e136..6da3d5feb 100644 --- a/Classes/ItemsTab.lua +++ b/Classes/ItemsTab.lua @@ -1569,22 +1569,22 @@ function ItemsTabClass:AddCustomModifierToDisplayItem() end end - -- Sorts modifiers by label - -- Ignores the initial magnitude part - -- Ex: "+10% ham" comes after "Gummybears" - table.sort(modList, function comparator(l, r) - local l_first_letter_index = string.find(l.label, "[%u%l]") - local r_first_letter_index = string.find(r.label, "[%u%l]") - - local lthunk = string.lower(string.sub(l.label, l_first_letter_index)) - local rthunk = string.lower(string.sub(r.label, r_first_letter_index)) - - if lthunk < rthunk then - return true - else - return false - end - end) + -- Sorts modifiers by label + -- Ignores the initial magnitude part + -- Ex: "+10% ham" comes after "Gummybears" + table.sort(modList, function comparator(l, r) + local l_first_letter_index = string.find(l.label, "[%u%l]") + local r_first_letter_index = string.find(r.label, "[%u%l]") + + local lthunk = string.lower(string.sub(l.label, l_first_letter_index)) + local rthunk = string.lower(string.sub(r.label, r_first_letter_index)) + + if lthunk < rthunk then + return true + else + return false + end + end) elseif sourceId == "ESSENCE" then for _, essence in pairs(self.build.data.essences) do local modId = essence.mods[self.displayItem.type]