Module:Character Infobox: Difference between revisions
From NOISZ Wiki
RiceEmpress (talk | contribs) No edit summary |
BrunoLaplace (talk | contribs) (use title1 argument if given instead of defaulting to page title) |
||
| (92 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
local capiunto = require 'capiunto' | local capiunto = require 'capiunto' | ||
local p = {} | local p = {} | ||
function p.main(frame) | function p.main(frame) | ||
local args = frame:getParent().args | |||
local infobox = capiunto.create( { | local infobox = capiunto.create( { | ||
title1 | title = args.title1 and args.title1 or tostring(mw.title.getCurrentTitle()) | ||
} ) | |||
:addImage( args.image1, args.caption ) | if args.image1 and string.find(args.image1 .. "e","%p(tabber)%p") then | ||
infobox:addImage(args.image1, args.caption) | |||
elseif args.image1 then | |||
infobox:addImage('[[File:' .. args.image1 .. '|200px]]', args.caption) | |||
end | |||
local attributes = | |||
{ | |||
{'Voice', args.voice }, | |||
{ 'JP Name', args.jp_name }, | |||
{ 'Also known as', args.also_known_as } | |||
} | |||
local physical = | |||
{ | |||
{ 'Eye Colour', args.eye_colour }, | |||
: | { 'Hair Colour', args.hair_colour }, | ||
{ 'Height', args.height } | |||
} | |||
local biographical = | |||
{ | |||
{ 'Age', args.age }, | |||
{ 'Birthday', args.birthday }, | |||
{ 'Likes', args.likes }, | |||
{ 'Dislikes', args.dislikes }, | |||
{ 'Relationships', args.relationships } | |||
} | |||
if args.voice or args.jp_name or args.also_known_as then | |||
for _, row in ipairs(attributes) do | |||
local label, value = row[1], row[2] | |||
if value and value ~= '' then | |||
infobox:addRow(label, value) | |||
end | |||
end | |||
end | |||
if args.eye_colour or args.hair_colour or args.height then | |||
infobox:addHeader( 'Physical' ) | |||
for _, row in ipairs(physical) do | |||
local label, value = row[1], row[2] | |||
if value and value ~= '' then | |||
infobox:addRow(label, value) | |||
end | |||
end | |||
end | |||
if args.age or args.birthday or args.likes or args.dislikes or args.relationships then | |||
infobox:addHeader( 'Biographical' ) | |||
for _, row in ipairs(biographical) do | |||
local label, value = row[1], row[2] | |||
if value and value ~= '' then | |||
infobox:addRow(label, value) | |||
end | |||
end | |||
end | |||
return infobox | return infobox | ||
end | end | ||
return p | return p | ||
Latest revision as of 10:25, 24 October 2025
Documentation for this module may be created at Module:Character Infobox/doc
local capiunto = require 'capiunto'
local p = {}
function p.main(frame)
local args = frame:getParent().args
local infobox = capiunto.create( {
title = args.title1 and args.title1 or tostring(mw.title.getCurrentTitle())
} )
if args.image1 and string.find(args.image1 .. "e","%p(tabber)%p") then
infobox:addImage(args.image1, args.caption)
elseif args.image1 then
infobox:addImage('[[File:' .. args.image1 .. '|200px]]', args.caption)
end
local attributes =
{
{'Voice', args.voice },
{ 'JP Name', args.jp_name },
{ 'Also known as', args.also_known_as }
}
local physical =
{
{ 'Eye Colour', args.eye_colour },
{ 'Hair Colour', args.hair_colour },
{ 'Height', args.height }
}
local biographical =
{
{ 'Age', args.age },
{ 'Birthday', args.birthday },
{ 'Likes', args.likes },
{ 'Dislikes', args.dislikes },
{ 'Relationships', args.relationships }
}
if args.voice or args.jp_name or args.also_known_as then
for _, row in ipairs(attributes) do
local label, value = row[1], row[2]
if value and value ~= '' then
infobox:addRow(label, value)
end
end
end
if args.eye_colour or args.hair_colour or args.height then
infobox:addHeader( 'Physical' )
for _, row in ipairs(physical) do
local label, value = row[1], row[2]
if value and value ~= '' then
infobox:addRow(label, value)
end
end
end
if args.age or args.birthday or args.likes or args.dislikes or args.relationships then
infobox:addHeader( 'Biographical' )
for _, row in ipairs(biographical) do
local label, value = row[1], row[2]
if value and value ~= '' then
infobox:addRow(label, value)
end
end
end
return infobox
end
return p