Added detection of bag of crafting content shifts

This commit is contained in:
Wofsauge committed 2021-05-30 20:31:28 +02:00
1 parent 1bd04bc72f
commit 9e837ac368
3 files changed
+29 -5

No files matched your search

+6 -4
View File
@@ -726,9 +726,10 @@ end
-- Example input: {1,2,3,4,5,6,7,8}
-- Result: "{{Crafting8}}{{Crafting7}}{{Crafting6}}{{Crafting5}}{{Crafting4}}{{Crafting3}}{{Crafting2}}{{Crafting1}}"
function EID:tableToCraftingIconsFull(craftTable)
table.sort(craftTable, function(a, b) return a > b end)
local sortedList = {table.unpack(craftTable)}
table.sort(sortedList, function(a, b) return a > b end)
local iconString = ""
for _,nr in ipairs(craftTable) do
for _,nr in ipairs(sortedList) do
iconString = iconString.."{{Crafting"..nr.."}}"
end
return iconString
@@ -738,9 +739,10 @@ end
-- Example input: {1,1,1,2,2,3,3,3}
-- Result: "3{{Crafting3}}2{{Crafting2}}3{{Crafting1}}"
function EID:tableToCraftingIconsMerged(craftTable)
table.sort(craftTable, function(a, b) return a > b end)
local sortedList = {table.unpack(craftTable)}
table.sort(sortedList, function(a, b) return a > b end)
local filteredList = {}
for _,nr in ipairs(craftTable) do
for _,nr in ipairs(sortedList) do
if filteredList[nr] == nil then
filteredList[nr] = 1
else