Module:HeroData: Difference between revisions

Sur (talk | contribs)
m infobox values actually passed to infobox correctly
Sur (talk | contribs)
m icon/grey called
Line 99: Line 99:
     local label
     local label
     local postfix
     local postfix
     local shouldDisplay
     local should_display
    local image_file_name
    local image_file
    local icon_and_value_str
     local template_args = {}
     local template_args = {}
     local stat_values = {Weapon = "", Vitality = ""}
     local stat_values = {Weapon = "", Vitality = ""}
Line 130: Line 133:
postfix = lang_module._get_string(postfix)
postfix = lang_module._get_string(postfix)
end
end
-- Check if icon file exists, and if not, don't use any image
image_file_name = 'File:AttributeIcon' .. stat_name .. '.png'
-- 15px and link to stat name (page name might not match perfectly yet)
image_file = util_module.get_image_file(image_file_name, 15, stat_name)
icon_template_title = mw.title.new("Template:Icon/Grey")
icon_template_args = {}
icon_template_args[1] = image_file
icon_template_args[2] = stat_value .. postfix
icon_and_value_str = mw.getCurrentFrame():expandTemplate{ title = icon_template_title, args = icon_template_args }
-- First add localized stat name for left column
-- First add localized stat name for left column
stat_values[category] = stat_values[category] .. "," .. label
stat_values[category] = stat_values[category] .. "," .. label
-- Then add stat value for right column
-- Then add icon and stat value for right column
stat_values[category] = stat_values[category] .. "," .. stat_value .. postfix
stat_values[category] = stat_values[category] .. "," .. icon_and_value_str
end
end
Line 148: Line 161:
     return expanded_template
     return expanded_template
end
end




Line 213: Line 225:
-- Check if icon file exists, and if not, don't use any image
-- Check if icon file exists, and if not, don't use any image
image_file_name = 'File:AttributeIcon' .. stat_name .. '.png'
image_file_name = 'File:AttributeIcon' .. stat_name .. '.png'
image_file_name = util_module.get_image_file(image_file_name)
image_file = util_module.get_image_file(image_file_name)
-- Add an empty cell following some stats to align them correctly as seen in game
-- Add an empty cell following some stats to align them correctly as seen in game
Line 227: Line 239:
-- Set cell value as "Icon StatvaluePostfix Statname Scaling,"
-- Set cell value as "Icon StatvaluePostfix Statname Scaling,"
-- If icon file already exists, set it to #REDIRECT to the duplicate file page
-- If icon file already exists, set it to #REDIRECT to the duplicate file page
cell_value = image_file_name .. " " .. stat_value  .. postfix .. " " .. label .. " " .. scalar_str .. "," .. extra_blank_cell
cell_value = image_file .. " " .. stat_value  .. postfix .. " " .. label .. " " .. scalar_str .. "," .. extra_blank_cell
cell_values = cell_values .. cell_value --add value to values list
cell_values = cell_values .. cell_value --add value to values list