Module:ItemData/nav: Difference between revisionsGive feedback
m sort by souls first, then item name; seems it wasnt necessary since nothing seems to be different, call it future proof then |
m revert previous since its not needed and its time complexity is much worse; Undo revision 11448 by Sur (talk) Tag: Undo |
||
| Line 17: | Line 17: | ||
--Retrieve all items that fit the bounds | --Retrieve all items that fit the bounds | ||
local items = {} | local items = {} | ||
for item_key, item_data in pairs(items_data) do | for item_key, item_data in pairs(items_data) do | ||
local card | |||
if item_data['Disabled'] == nil and item_data['IsDisabled'] ~= nil then | if item_data['Disabled'] == nil and item_data['IsDisabled'] ~= nil then | ||
return "REMINDER: 'Disabled' was renamed to 'IsDisabled'" | return "REMINDER: 'Disabled' was renamed to 'IsDisabled'" | ||
end | end | ||
local cost = tonumber(item_data["Cost"]) | local cost = tonumber(item_data["Cost"]) | ||
local slot_ = item_data["Slot"] | local slot_ = item_data["Slot"] | ||
if item_data["Name"] ~= nil and item_data["Disabled"] == false and cost ~= nil and slot ~= nil then | if item_data["Name"] ~= nil and item_data["Disabled"] == false and cost ~= nil and slot ~= nil then | ||
if slot == slot_ and cost>=min_souls and cost<max_souls then | if slot == slot_ and cost>=min_souls and cost<max_souls then | ||
table.insert(items, lang_module.get_string(item_key)) | |||
table.insert(items | |||
end | end | ||
end | end | ||
end | end | ||
--Order | --Order list alphabetically | ||
table.sort(items) --O(nlogn) | |||
--Add each item to output | --Add each item to output | ||
local ret = '' | local ret = '' | ||
for index, item_name in ipairs(items) do | |||
ret = ret .. '{{ItemIcon|' .. item_name .. '}} • ' | |||
end | end | ||