Module:HeroData: Difference between revisions

Jump to navigation Jump to search
completed hero tags list
simplified get_hero_tag parameters
Line 701: Line 701:
-- Function to call hero tags based on name
-- Function to call hero tags based on name
p.get_hero_tag = function (frame)
p.get_hero_tag = function (frame)
     local input_name = frame.args[1]
     local name = frame.args[1]
     local input_number = tonumber(frame.args[2])
     local number = tonumber(frame.args[2])


     -- Validate input
     -- Validate input
     if not input_name then
     if not name then
         return "Error: Missing name input."
         return "Error: Missing name input."
     end
     end


     if input_number ~= 1 and input_number ~= 2 and input_number ~= 3 then
     if number ~= 1 and number ~= 2 and number ~= 3 then
         return string.format("Error: Invalid number '%s'. Must be 1, 2, or 3.", tostring(frame.args[2]))
         return string.format("Error: Invalid number '%s'. Must be 1, 2, or 3.", tostring(frame.args[2]))
     end
     end


     local tagname = TAG_NAME_MAP[input_name]
     local tagname = TAG_NAME_MAP[name]
     if not tagname then
     if not tagname then
         return string.format("Error: Unknown name '%s'.", input_name)
         return string.format("Error: Unknown name '%s'.", name)
     end
     end


     -- Build localization key
     -- Build localization key
     local key = string.format("Citadel_%s_HeroTag_%d", tagname, input_number)
     local key = string.format("Citadel_%s_HeroTag_%d", tagname, number)


     -- Call Lang.get_string
     -- Call Lang.get_string