Module:Sandbox/One Bar: Difference between revisions

One Bar (talk | contribs)
Add variable name
One Bar (talk | contribs)
keep variable as key
Line 3: Line 3:


local function get_disabled_items_array()
local function get_disabled_items_array()
local similarItems = {}
local disabledItems = {}
local hash = {}
for k, v in pairs(data) do
local noDuplicates = {}
for _, v in pairs(data) do
if (v["IsDisabled"] == true and v["Name"] ~= nil) then
if (v["IsDisabled"] == true and v["Name"] ~= nil) then
table.insert(similarItems, v)
disabledItems[k] = v
end
end
end
end
return disabledItems
-- 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