Module:Abilities/utils: Difference between revisionsGive feedback
added find_hero_by_ability |
mNo edit summary Tag: Manual revert |
||
| (11 intermediate revisions by 3 users not shown) | |||
| Line 22: | Line 22: | ||
-- Returns the key of the hero whose ability name is passed as an argument | -- Returns the key of the hero whose ability name is passed as an argument | ||
--{{#invoke: | --{{#invoke:Abilities/utils|find_hero_by_ability|ABILITY_NAME}}-- | ||
p.find_hero_by_ability = function(frame) | p.find_hero_by_ability = function(frame) | ||
local ability_name = frame.args[1] | local ability_name = frame.args[1] | ||
| Line 29: | Line 29: | ||
return "Missing Ability Name" | return "Missing Ability Name" | ||
end | end | ||
-- Normalize input for case-insensitive comparison | |||
local normalized_input = string.lower(ability_name) | |||
-- Iterate through all heroes in the data | -- Iterate through all heroes in the data | ||
| Line 34: | Line 37: | ||
-- Check each ability for this hero | -- Check each ability for this hero | ||
for ability_num, ability in pairs(ui_data) do | for ability_num, ability in pairs(ui_data) do | ||
local current_name = | local current_name = lang.get_string(ability.Key) | ||
if current_name == | if string.lower(current_name) == normalized_input then | ||
return hero_key | return hero_key | ||
end | end | ||