Module:Abilities/utils: Difference between revisions

Updated uom styling
mNo edit summary
Tag: Manual revert
 
(12 intermediate revisions by 3 users not shown)
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:Abilities/utils|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
-- Normalize input for case-insensitive comparison
local normalized_input = string.lower(ability_name)
-- 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 string.lower(current_name) == normalized_input then
return hero_key
end
end
end
return "Hero Not Found"
end
end