Module:ItemTables: Difference between revisions

Jump to navigation Jump to search
Undo revision 12069 by Sylphoid (talk) move up catch
remove duplicate items in similar items
Line 11: Line 11:
local function get_similar_items_array(property)
local function get_similar_items_array(property)
local similarItems = {}
local similarItems = {}
local hash = {}
local noDuplicates = {}
for _, v in pairs(data) do
for _, v in pairs(data) do
for _, value in ipairs(property) do
for _, value in ipairs(property) do
Line 18: Line 20:
end
end
end
end
return similarItems
-- remove duplicate items if that item contains multiple keys of the same stat increase (eg. Fleetfoot has both "BonusMoveSpeed", "ActiveBonusMoveSpeed" in move speed).
-- there might be a more efficient way to prevent adding duplicate items in the first place in the above for loop
for _, v in pairs(similarItems) do
if (not hash[v]) then
noDuplicates[#noDuplicates+1] = v
hash[v] = true
end
end
return noDuplicates
end
end