Módulo:CharacterInfobox: mudanças entre as edições
De Cronicas Eternas Wiki
Sem resumo de edição |
Sem resumo de edição |
||
Linha 4: | Linha 4: | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
-- Define a ordem e os campos das seções | |||
local sections = { | local sections = { | ||
["IMAGEM"] = {}, -- Adicionado para garantir a exibição da imagem no topo | |||
["INFORMAÇÕES BÁSICAS"] = { | ["INFORMAÇÕES BÁSICAS"] = { | ||
{"Títulos", args["titles"]}, | {"Títulos", args["titles"]}, | ||
Linha 45: | Linha 47: | ||
} | } | ||
-- Início da infobox | -- Início da infobox | ||
local infobox = '<div style="width:22em; background:#f9f9f9; border:1px solid #aaa; float:right; padding:5px; font-size:90%;">' | local infobox = '<div style="width:22em; background:#f9f9f9; border:1px solid #aaa; float:right; padding:5px; font-size:90%;">' | ||
Linha 62: | Linha 64: | ||
) | ) | ||
-- Adiciona as seções e campos | -- Adiciona as seções e os campos em ordem definida | ||
for section, fields in pairs(sections) do | for section, fields in pairs(sections) do | ||
infobox = infobox .. string.format('<div style="text-align:center; background:#ddd; font-size:110%%; padding:4px; margin-top:5px;">%s</div>', section) | if #fields > 0 then | ||
infobox = infobox .. string.format('<div style="text-align:center; background:#ddd; font-size:110%%; padding:4px; margin-top:5px;">%s</div>', section) | |||
for _, field in ipairs(fields) do | |||
local label, value = field[1], field[2] | |||
if value and value ~= "" then | |||
infobox = infobox .. string.format('<div style="padding:2px 5px;"><strong>%s:</strong> %s</div>', label, value) | |||
end | |||
end | end | ||
end | end |
Edição das 01h20min de 23 de novembro de 2024
A documentação para este módulo pode ser criada em Módulo:CharacterInfobox/doc
local p = {}
function p.infobox(frame)
local args = frame:getParent().args
-- Define a ordem e os campos das seções
local sections = {
["IMAGEM"] = {}, -- Adicionado para garantir a exibição da imagem no topo
["INFORMAÇÕES BÁSICAS"] = {
{"Títulos", args["titles"]},
{"Conhecido como", args["known_as"]},
{"Apelidos", args["nicknames"]},
{"Nome verdadeiro", args["real_name"]},
{"Lar", args["home"]},
{"Lares anteriores", args["previous_homes"]},
{"Sexo", args["gender"]},
{"Espécie", args["species"]},
{"Etnia", args["ethnicity"]},
{"Ocupação", args["occupation"]},
{"Idade", args["age"]},
{"Divindade Padroeira", args["patron_deity"]},
{"Linguagens", args["languages"]},
},
["DATAS"] = {
{"Nascido", args["born"]},
{"Transformado", args["transformed"]},
{"Morte", args["death"]},
{"Destruído", args["destroyed"]},
},
["FAMÍLIA"] = {
{"Pais", args["parents"]},
{"Irmãos", args["siblings"]},
{"Filhos", args["children"]},
{"Parentes", args["relatives"]},
},
["DINASTIA"] = {
{"Início de reinado", args["reign_start"]},
{"Fim de reinado", args["reign_end"]},
{"Predecessor", args["predecessor"]},
{"Sucessor", args["successor"]},
},
["INFORMAÇÕES MECÂNICAS"] = {
{"Alinhamento", args["alignment"]},
{"Nível de desafio", args["challenge_rating"]},
{"Classe", args["class"]},
},
}
-- Início da infobox
local infobox = '<div style="width:22em; background:#f9f9f9; border:1px solid #aaa; float:right; padding:5px; font-size:90%;">'
-- Adiciona a imagem no topo, se fornecida
if args["image"] and args["image"] ~= "" then
infobox = infobox .. string.format(
'<div style="text-align:center; margin-bottom:10px;">%s</div>',
frame:preprocess(string.format('[[File:%s|center|frameless|200px]]', args["image"]))
)
end
-- Adiciona o nome do personagem
infobox = infobox .. string.format(
'<div style="text-align:center; background:#ccc; font-size:120%%; padding:4px;">%s</div>',
args["name"] or "NOME DO PERSONAGEM"
)
-- Adiciona as seções e os campos em ordem definida
for section, fields in pairs(sections) do
if #fields > 0 then
infobox = infobox .. string.format('<div style="text-align:center; background:#ddd; font-size:110%%; padding:4px; margin-top:5px;">%s</div>', section)
for _, field in ipairs(fields) do
local label, value = field[1], field[2]
if value and value ~= "" then
infobox = infobox .. string.format('<div style="padding:2px 5px;"><strong>%s:</strong> %s</div>', label, value)
end
end
end
end
infobox = infobox .. '</div>'
return infobox
end
return p