Module:Abilities/card: Difference between revisionsGive feedback
mNo edit summary |
mNo edit summary |
||
| Line 9: | Line 9: | ||
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") | ||
local | if not resource_lookup then return nil end | ||
local key = tostring(hero_name):lower() | |||
local entry = resource_lookup[key] | |||
if not entry then | if not entry then | ||
return nil | return nil | ||
end | end | ||
return entry.key | return entry.key | ||
end | end | ||