Module:HeroData: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Gammaton32 (talk | contribs) use ground dash speed instead of duration |
Gammaton32 (talk | contribs) moved get_hero_key function from Module:HeroData/Name |
||
| Line 34: | Line 34: | ||
-- returns the key of the specified hero's english name | -- returns the key of the specified hero's english name | ||
function p.get_hero_key(name) | function p.get_hero_key(name) | ||
local hero_name_input = frame.args[1] -- Get the hero name from the template argument | |||
if not hero_name_input then | |||
return "Error: Hero name not specified." | |||
end | |||
hero_name_input = hero_name_input:lower() -- For case-independent search | |||
-- Go through all the characters and look for a name match. | |||
for hero_key, hero_data in pairs(heroes_data) do | |||
if hero_data["Name"] then | |||
local current_hero_name = hero_data["Name"]:lower() | |||
if current_hero_name == hero_name_input then | |||
return hero_key -- Return the key if the name matches | |||
end | |||
end | |||
end | |||
return "Hero not found." -- If nothing is found | |||
end | end | ||
--{{#invoke:HeroData|get_hero_var|HERO_NAME|STAT_NAME|sig_figs_or_localize}}-- | --{{#invoke:HeroData|get_hero_var|HERO_NAME|STAT_NAME|sig_figs_or_localize}}-- | ||