Module:Character Colors
Documentation for this module may be created at Module:Character Colors/doc
local p = {}
local colors = {
AEMIL = {
eyes = { "red", "green" },
horns = { '#E29A56' },
body = { '#56EB8E' }
}
}
function p.get_table_for_character(frame)
local character = frame.args[1]
local result = {}
local append_color_blocks = function(colors, color_type)
for i, color in pairs(colors[color_type]) do
local is_hex_code = string.find(color, "#") ~= nil
if (is_hex_code) then
result[#result + 1] = '<div style="background-color: ' .. color .. '"><strong><div style="color: white; border: 1px solid gray; padding: 4px 10px;">' .. color .. '</div></strong></div>'
else
result[#result + 1] = '<div><strong><div style="border: 2px solid ' .. color .. '; padding: 4px 10px;">' .. color .. '</div></strong></div>'
end
end
end
result[#result + 1] = '{| class="wikitable" style="width: 100%; margin: 0;"'
result[#result + 1] = '|-'
result[#result + 1] = '! scope="col" style="width: 50px"; | Eyes'
result[#result + 1] = '| <div style="display: flex; flex-flow: column">'
append_color_blocks(colors[character], "eyes")
result[#result + 1] = '</div>'
result[#result + 1] = '|-'
result[#result + 1] = '! scope="col" style="width: 50px"; | Horns'
result[#result + 1] = '| <div style="display: flex; flex-flow: column">'
append_color_blocks(colors[character], "horns")
result[#result + 1] = '</div>'
result[#result + 1] = '|-'
result[#result + 1] = '! scope="col" style="width: 50px"; | Body'
result[#result + 1] = '| <div style="display: flex; flex-flow: column">'
append_color_blocks(colors[character], "body")
result[#result + 1] = '</div>'
result[#result + 1] = '|}'
return table.concat(result, "\n")
end
return p