Module:HeroData: Difference between revisionsGive feedback
m write_hero_comparison_table fully functioning version |
m hero comparison; stats colored by category |
||
| Line 355: | Line 355: | ||
-- Initializations and declarations | -- Initializations and declarations | ||
local row_str = "" | local row_str = "" | ||
local body_str = "" | local body_str = "" | ||
-- Iterate heroes | -- Iterate heroes | ||
| Line 379: | Line 376: | ||
-- Iterate attributes within the category | -- Iterate attributes within the category | ||
for _, attr_key in ipairs(attribute_orders[category]["attribute_order"]) do | for _, attr_key in ipairs(attribute_orders[category]["attribute_order"]) do | ||
attr_data = category_attrs[attr_key] | attr_data = category_attrs[attr_key] | ||
--Retrieve the stats value from hero data | --Retrieve the stats value from hero data | ||
stat_value = hero_data[attr_key] | stat_value = hero_data[attr_key] | ||
| Line 411: | Line 399: | ||
-- First header is Hero | -- First header is Hero | ||
local headers_str = "<th>" .. "Hero" .. "</th>" | local headers_str = "<th>" .. "Hero" .. "</th>" | ||
local header_style = "" | |||
local category_data = attribute_module.get_category_data() | |||
-- | -- Iterate stats again for displaying headers with their respective color | ||
for | for _, category in ipairs(attribute_orders["category_order"]) do | ||
headers_str = headers_str .. "<th>" .. | category_attrs = attributes_data[category] | ||
category_rgb = category_data[category]["rgb"] | |||
-- Iterate attributes within the category | |||
for _, attr_key in ipairs(attribute_orders[category]["attribute_order"]) do | |||
attr_data = category_attrs[attr_key] | |||
-- Localize, fallback to attr_key | |||
attr_localized = lang_module._get_string(attr_data["label"]) | |||
if (attr_localized == nil) then attr_localized = attr_key end | |||
header_style = ' style="background-color: ' .. "rgb(" .. category_rgb .. ') ;"' | |||
headers_str = headers_str .. "<th" .. header_style .. ">" .. attr_localized .. "</th>" | |||
end | |||
end | end | ||
headers_str = "<tr>" .. headers_str .. "</tr>" | headers_str = "<tr>" .. headers_str .. "</tr>" | ||
return '<table class="wikitable sortable">' .. headers_str .. body_str .. "</table>" | return '<table class="wikitable sortable">' .. headers_str .. body_str .. "</table>" | ||