Module:Character Colors: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 17: | Line 17: | ||
local is_hex_code = string.find(color, "#") ~= nil | local is_hex_code = string.find(color, "#") ~= nil | ||
if (is_hex_code) then | 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 | else | ||
result[#result + 1] = '<div><strong><div style="border: 2px solid ' .. color .. '; padding: 4px 10px;">' .. color .. '</div></strong></div>' | result[#result + 1] = '<div><strong><div style="border: 2px solid ' .. color .. '; padding: 4px 10px;">' .. color .. '</div></strong></div>' | ||
Revision as of 20:08, 13 December 2023
Documentation for this module may be created at Module:Character Colors/doc
local p = {}
local colors = {
AEMIL = {
eyes = {
}
}
}
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; col>'
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; col>'
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; col>'
append_color_blocks(colors[character], "body")
result[#result + 1] = '</div>'
return table.concat(result, "\n")
end
return p