Module:TierColor
Documentation for this module may be created at Module:TierColor/doc
local p = {}
local number_to_color_map = { -- Colors to correspond to a given zone tier, feel free to change if you think it would look better
['1'] = '#ADFF2F',
['2'] = '#D6EB18',
['3'] = '#FFD700',
['4'] = '#FFA500',
['5'] = '#FF7500',
['6'] = '#FF4500',
['7'] = 'Plum',
['8'] = 'PaleTurquoise',
}
function p.recolor_numbers(frame)
local input_string = tostring(frame.args[1] or '')
if frame.args[2] == "false" then -- Option for uncolored table, give back input
return input_string
end
local output_parts = {}
for i = 1, #input_string do -- Split up numbers and apply color to each
local char = input_string:sub(i, i)
if number_to_color_map[char] then
local color_code = number_to_color_map[char]
table.insert(output_parts, '<span style="color:' .. color_code .. ';font-weight: 500;">' .. char .. '</span>') -- I think 500 font weight looks better for colored, default 700 for uncolored
else
table.insert(output_parts, char)
end
end
return table.concat(output_parts)
end
function p.main(frame)
return p.recolor_numbers(frame)
end
return p