Module:HeroData/navGive feedback
Overview
Generates hero navigation cards
Functions
get_hero_nav_cards
For Template:Hero Navbox on Heroes, individual hero pages like Abrams, and the home page.
Examples
First with debug_mode on, to help visualize what the output's source looks like.
{{#invoke:HeroData/nav|get_hero_nav_cards
|text_size=13
|card_size=88
|in_herolabs=false
|debug_mode=true
}}
First parameter must be Current or Upcoming
Now with debug_mode defaulted to false (off) to see actual visual output.
{{#invoke:HeroData/nav|get_hero_nav_cards
|text_size=13
|card_size=88
|in_herolabs=false
}}
First parameter must be Current or Upcoming
Parameters
- text_size - Font size of the hero name
- card_size - Size of the hero card
- in_herolabs - Get hero labs heroes (there are none at the moment)
- debug_mode - (OPTIONAL) Defaults to false. With true, the output is raw wikitext source that isn't processed, allowing to see more clearly what is ran.
debug_mode is the only optional parameter. All other parameters are required. Template:Hero card2 utilizes this with some default values, see there for suggested values.
get_hero_roster
For Template:Roster on Heroes, generate a list using Template:HeroRosterCard.
get_hero_bulletpoints
For navboxes such as Template:Quotes Navbox, generate a bulletpoint list of heroes.
Add the name of a subpage to link to specific subpages. It will still display only the hero name but link to the subpage instead.
Add variable "no_redlinks=true" to hide red links (non-existent pages).
Examples
{{#invoke:HeroData/nav|get_hero_bulletpoints}}
Script error: The function "get_hero_bulletpoints" does not exist.
To link to "/Movement" subpages:
{{#invoke:HeroData/nav|get_hero_bulletpoints|Movement}}
Script error: The function "get_hero_bulletpoints" does not exist.
Hide redlinks:
{{#invoke:HeroData/nav|get_hero_bulletpoints|Movement|no_redlinks=true}}
Script error: The function "get_hero_bulletpoints" does not exist.
local p = {}
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local lang_module = require('Module:Lang')
-- for [[Template:Hero Navbox]], i.e. {{Hero Card Nav|Hero=Abrams}} {{Hero Card Nav|Hero=Bebop}}
function p.get_hero_nav_cards(frame)
local current_or_upcoming = frame.args[1]
if current_or_upcoming ~= 'Current' and current_or_upcoming ~= 'Upcoming' then
return 'First parameter must be Current or Upcoming'
end
local ret = ''
for hero_key, hero_data in pairs(heroes_data) do
local card = ''
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
card = '{{Hero Card Nav|Hero=' .. lang_module.get_string(hero_key) .. '}}'
end
ret = ret .. card .. ' '
end
end
return ret
end
return p