Module:ItemData/nav: Difference between revisionsGive feedback
m concat card to ret earlier |
m process to a list then sort it alphabetically before returning the string |
||
| Line 15: | Line 15: | ||
if min_souls == nil or max_souls == nil then return 'Min/Max souls must be numerical' end | if min_souls == nil or max_souls == nil then return 'Min/Max souls must be numerical' end | ||
local | --Retrieve all items that fit the bounds | ||
local items = {} | |||
for item_key, item_data in pairs(items_data) do | for item_key, item_data in pairs(items_data) do | ||
local card | local card | ||
| Line 26: | Line 27: | ||
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)) | |||
end | end | ||
end | end | ||
end | |||
--Order list alphabetically | |||
table.sort(items) --O(nlogn) | |||
--Add each item to output | |||
local ret = '' | |||
for index, item_name in ipairs(items) do | |||
ret = ret .. '{{ItemIcon|' .. item_name .. '}} • ' | |||
end | end | ||