Editing Module:Abilities/cardGive feedback
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 10: | Line 10: | ||
function get_hero_key(hero_name) | function get_hero_key(hero_name) | ||
if hero_name == | if not hero_name or hero_name == "" then return nil end | ||
-- if name starts with "hero_", use it directly as the key | -- if name starts with "hero_", use it directly as the key | ||
if string.sub(hero_name, 1, 5) == "hero_" then return hero_name end | if string.sub(hero_name, 1, 5) == "hero_" then return hero_name end | ||
local resource_lookup = mw.loadJsonData("Data:ResourceLookup.json") | local resource_lookup = mw.loadJsonData("Data:ResourceLookup.json") | ||
return | if not resource_lookup then return nil end | ||
local key = tostring(hero_name):lower() | |||
local entry = resource_lookup[key] | |||
if not entry then | |||
return nil | |||
end | |||
return entry.key | |||
end | end | ||