Module:ItemData/nav: Difference between revisionsGive feedback
m testing ordering by soul count first again |
Tag: Undo |
||
| Line 29: | Line 29: | ||
--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 | ||
--future proofing; Disabled will be renamed to IsDisabled soon | |||
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'" | ||
| Line 38: | Line 37: | ||
local this_cost = tonumber(item_data["Cost"]) | local this_cost = tonumber(item_data["Cost"]) | ||
local this_slot = item_data["Slot"] | local this_slot = item_data["Slot"] | ||
if item_data["Name"] ~= nil and item_data["Disabled"] == false and this_cost ~= nil and this_slot ~= nil then | if item_data["Name"] ~= nil and item_data["Disabled"] == false and this_cost ~= nil and this_slot ~= nil then | ||
if slot == this_slot and this_cost>=min_souls and this_cost<max_souls then | if slot == this_slot and this_cost>=min_souls and this_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 | ||
-- Each item is surrounded by left and right wrap, and separated by sep | |||
local ret = '' | local ret = '' | ||
for index, item_name in ipairs(items) do | |||
ret = ret .. left_wrap .. item_name .. right_wrap .. sep | |||
end | end | ||