Module:Abilities/utils: Difference between revisions

Updated uom styling
added find_hero_by_ability
Line 19: Line 19:
end
end
return nil
return nil
end
-- Returns the key of the hero whose ability name is passed as an argument
--{{#invoke:AbilityData|find_hero_by_ability|ABILITY_NAME}}--
p.find_hero_by_ability = function(frame)
local ability_name = frame.args[1]
if not ability_name or ability_name == "" then
return "Missing Ability Name"
end
-- Iterate through all heroes in the data
for hero_key, ui_data in pairs(data) do
-- Check each ability for this hero
for ability_num, ability in pairs(ui_data) do
local current_name = Lang.get_string(ability.Key)
if current_name == ability_name then
return hero_key
end
end
end
return "Hero Not Found"
end
end