Module:HeroData: Difference between revisionsGive feedback
m write_hero_comparison_table save |
m write_hero_comparison_table fully functioning version |
||
| Line 358: | Line 358: | ||
local row_str = "" | local row_str = "" | ||
local body_str = "" | local body_str = "" | ||
local first_hero = true | |||
| Line 375: | Line 374: | ||
-- Consecutive columns are then stats | -- Consecutive columns are then stats | ||
-- Iterate categories | -- Iterate categories | ||
for category | for _, category in ipairs(attribute_orders["category_order"]) do | ||
category_attrs = attributes_data[category] | |||
-- Iterate attributes within the category | -- Iterate attributes within the category | ||
for attr_key | for _, attr_key in ipairs(attribute_orders[category]["attribute_order"]) do | ||
-- | attr_data = category_attrs[attr_key] | ||
attr_localized = lang_module._get_string(attr_data["label"]) | |||
-- If its the first iteration, add the attribute to the list of headers | |||
if (first_hero) then | |||
-- Localize, fallback to attr_key | |||
attr_localized = lang_module._get_string(attr_data["label"]) | |||
if (attr_localized == nil) then attr_localized = attr_key end | |||
headers[#headers+1] = attr_localized | |||
end | |||
--Retrieve the stats value from hero data | --Retrieve the stats value from hero data | ||
| Line 395: | Line 400: | ||
end | end | ||
end | end | ||
-- Add row to the body | -- Add row to the body | ||
row_str = "<tr>" .. row_str .. "</tr>" | row_str = "<tr>" .. row_str .. "</tr>" | ||
body_str = body_str .. row_str | body_str = body_str .. row_str | ||
first_hero = false | |||
end | end | ||
| Line 405: | Line 413: | ||
-- Turn headers list to string | -- Turn headers list to string | ||
for header | for index, header in ipairs(headers) do | ||
headers_str = headers_str .. "<th>" .. header .. "</th>" | headers_str = headers_str .. "<th>" .. header .. "</th>" | ||
end | end | ||