Module:HeroData: Difference between revisions

use ground dash speed instead of duration
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)
for i,v in pairs(heroes_data) do
    local hero_name_input = frame.args[1] -- Get the hero name from the template argument
if (v["Name"] == name) then
    if not hero_name_input then
return i
        return "Error: Hero name not specified."
end
    end
end
 
return nil
    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}}--