Module:Infobox character

-- -- Module for Template:Infobox character

local getArgs  = require('Module:Arguments').getArgs local InfoboxBuilder = require('Module:InfoboxBuilder') local DisplayFns    = require('Module:DisplayFunctions') local ProcessingFns = require('Module:ProcessingFunctions') local constants = require('Module:Constants')

local p = {}

local function formatColor(color) if color and color ~= nil then return string.format(			"%s  ",			color,			color		); end end

local function formatHometown(list) if list == nil then return nil end return table.concat(list, ' ') end

function p.main(frame) local args = getArgs(frame) local infobox = InfoboxBuilder.new; infobox:setName('Infobox character') :setParams{ { name = 'character name', default = mw.title.getCurrentTitle.text }, { name = 'character image' }, { name = 'Current' }, { name = 'Former' }, { name = 'english' }, { name = 'position' }, { name = 'Alias' }, { name = 'Age' }, { name = 'Cause of Death' }, { name = 'Kit' }, { name = 'Apprentice' }, { name = 'Medicine Cat Apprentice' }, { name = 'Warrior' }, { name = 'Senior Warrior' }, { name = 'Queen' }, { name = 'Deputy' }, { name = 'Leader' }, { name = 'Elder' }, { name = 'Loner' }, { name = 'StarClan resident' }, { name = 'Mother' }, { name = 'Father' }, { name = 'Sister' }, { name = 'Brother' }, { name = 'Mate' }, { name = 'Daughters' }, { name = 'Sons' }, { name = 'Mentor' }, { name = 'Apprentice' }, { name = 'Preceded by' }, { name = 'Succeeded By' }, { name = 'Preceded by' }, { name = 'Succeeded By' }, { name = 'color' }, }		:setArgs(args) :processArgs if args['color'] and args['color'] ~= '' then infobox:setHeaderBackgroundColor(args['color']) end

infobox :addHeader({ tag = 'argth', content = 'character name' }) :addImage :addHeader({ tag = 'th', content = 'Affiliations' }, { subheader = true }) :addRow(			{				{ tag = 'th', content = 'Current' },				{ tag = 'argtd', content = 'current' }			}		) :addRow(			{				{ tag = 'th', content = 'Former' },				{ tag = 'argtd', content = 'former' }			}		) :addHeader({ tag = 'th', content = 'Biographical information' }, { subheader = true }) :addRow(			{				{ tag = 'th', content = 'Alias(es)' },				{ tag = 'argtd', content = 'alias' }			},			{ hideIfEmpty = { 'alias' } }		) :addRow(			{				{ tag = 'th', content = 'Age' },				{ tag = 'argtd', content = 'age' }			}		) :addRow(			{				{ tag = 'th', content = 'Cause of Death' },				{ tag = 'argtd', content = 'cod' }			}		) :addHeader({ tag = 'th', content = 'Names' }, { subheader = true }) :addRow(			{				{ tag = 'th', content = 'Kit' },				{ tag = 'argtd', content = 'kit' }			}		) :addRow(			{				{ tag = 'th', content = 'Apprentice' },				{ tag = 'argtd', content = 'apprentice' }			},			{ hideIfEmpty = { 'apprentice' } }		) :addRow(			{				{ tag = 'th', content = 'Medicine Cat Apprentice' },				{ tag = 'argtd', content = 'medicine cat apprentice' }			},			{ hideIfEmpty = { 'medicine cat apprentice' } }		) :addRow(			{				{ tag = 'th', content = 'Warrior' },				{ tag = 'argtd', content = 'warrior' }			},			{ hideIfEmpty = { 'warrior' } }		) :addRow(			{				{ tag = 'th', content = 'Senior Warrior' },				{ tag = 'argtd', content = 'senior warrior' }			},			{ hideIfEmpty = { 'senior warrior' } }		) :addRow(			{				{ tag = 'th', content = 'Queen' },				{ tag = 'argtd', content = 'queen' }			},			{ hideIfEmpty = { 'queen' } }		) :addRow(			{				{ tag = 'th', content = 'Deputy' },				{ tag = 'argtd', content = 'deputy' }			},			{ hideIfEmpty = { 'deputy' } }		) :addRow(			{				{ tag = 'th', content = 'Leader' },				{ tag = 'argtd', content = 'leader' }			},			{ hideIfEmpty = { 'leader' } }		) :addRow(			{				{ tag = 'th', content = 'Elder' },				{ tag = 'argtd', content = 'elder' }			},			{ hideIfEmpty = { 'elder' } }		) :addRow(			{				{ tag = 'th', content = 'Loner' },				{ tag = 'argtd', content = 'loner' }			},			{ hideIfEmpty = { 'loner' } }		) :addRow(			{				{ tag = 'th', content = 'StarClan resident' },				{ tag = 'argtd', content = 'starclan resident' }			},			{ hideIfEmpty = { 'starclan resident' } }		) :addHeader({ tag = 'th', content = 'Kin' }, { subheader = true }) :addRow(			{				{ tag = 'th', content = 'Mother' },				{ tag = 'argtd', content = 'mother' }			},			{ hideIfEmpty = { 'mother' } }		) :addRow(			{				{ tag = 'th', content = 'Father' },				{ tag = 'argtd', content = 'father' }			},			{ hideIfEmpty = { 'father' } }		) :addRow(			{				{ tag = 'th', content = 'Sister' },				{ tag = 'argtd', content = 'sister' }			},			{ hideIfEmpty = { 'sister' } }		) :addRow(			{				{ tag = 'th', content = 'Brother' },				{ tag = 'argtd', content = 'brother' }			},			{ hideIfEmpty = { 'brother' } }		) :addRow(			{				{ tag = 'th', content = 'Mate' },				{ tag = 'argtd', content = 'mate' }			},			{ hideIfEmpty = { 'mate' } }		) :addRow(			{				{ tag = 'th', content = 'Daughters' },				{ tag = 'argtd', content = 'daughters' }			},			{ hideIfEmpty = { 'daughters' } }		) :addRow(			{				{ tag = 'th', content = 'Sons' },				{ tag = 'argtd', content = 'sons' }			},			{ hideIfEmpty = { 'sons' } }		) :addHeader({ tag = 'th', content = 'Education' }, { subheader = true }) :addRow(			{				{ tag = 'th', content = 'Mentor' },				{ tag = 'argtd', content = 'mentor' }			}		) :addRow(			{				{ tag = 'th', content = 'Apprentice' },				{ tag = 'argtd', content = 'apprentice' }			},			{ hideIfEmpty = { 'apprentice' } }		) :addHeader({ tag = 'th', content = 'Leader Position' }, { subheader = true }) :addRow(			{				{ tag = 'th', content = 'Preceded By' },				{ tag = 'argtd', content = 'leadpreceded by' }			},			{ hideIfEmpty = { 'leadpreceded by' } }		) :addRow(			{				{ tag = 'th', content = 'Succeeded By' },				{ tag = 'argtd', content = 'depsucceeded by' }			},			{ hideIfEmpty = { 'leadsucceeded by' } }		) :addHeader({ tag = 'th', content = 'Deputy Position' }, { subheader = true }) :addRow(			{				{ tag = 'th', content = 'Preceded By' },				{ tag = 'argtd', content = 'depreceded by' }			},			{ hideIfEmpty = { 'depreceded by' } }		) :addRow(			{				{ tag = 'th', content = 'Succeeded By' },				{ tag = 'argtd', content = 'depsucceeded by' }			},			{ hideIfEmpty = { 'depsucceeded by' } }		) :addRow(			{				{ tag = 'th', content = 'Image color' },				{ tag = 'argtd', content = 'color', fn = formatColor }			}		) local categories = "" if mw.title.getCurrentTitle.namespace == 0 then categories = "" .. categories end

return infobox:tostring .. categories end

return p