Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:HeroData/nav: Difference between revisions

From Deadlock Wiki
Sur (talk | contribs)
m concat card to ret earlier
Sur (talk | contribs)
m now sorts the heroes alphabetically
Line 10: Line 10:
end
end
local ret = ''
local heroes = {}
for hero_key, hero_data in pairs(heroes_data) do
for hero_key, hero_data in pairs(heroes_data) do
local card
local card = ''
if hero_data["Name"] ~= nil and hero_data["IsDisabled"] == false then
if hero_data["Name"] ~= nil and hero_data["IsDisabled"] == false then
if (hero_data["InDevelopment"] == false and current_or_upcoming == 'Current' or hero_data["InDevelopment"] == true and current_or_upcoming == 'Upcoming') then
if (hero_data["InDevelopment"] == false and current_or_upcoming == 'Current' or hero_data["InDevelopment"] == true and current_or_upcoming == 'Upcoming') then
card = '{{Hero Card Nav|Hero=' .. lang_module.get_string(hero_key) .. '}}'
table.insert(heroes, lang_module.get_string(hero_key))
ret = ret .. card .. ' '
end
end
end
end
end
end
--Order list alphabetically
table.sort(heroes) --O(nlogn)
--Add each item to output
local ret = ''
for index, hero_name in ipairs(heroes) do
ret = ret .. '{{Hero Card Nav|Hero=' .. hero_name .. '}} '
end
--Remove the last space
ret = string.sub(ret, 1, -(string.len(' '))-1)
return frame:preprocess(ret)
return frame:preprocess(ret)
end
end


return p
return p