Module:Character

From The Coffin of Andy and Leyley

Revision as of 03:54, 1 January 2024 by Ashley Graves (talk | contribs)

Documentation for this module may be created at Module:Character/doc

local capiunto = require 'capiunto'

local p = {}

local function v( val, name )
	return (val ~= nil) and (type( val ) == 'string' or type( val ) == 'number')
end

function p.main(frame)
	local args = frame:getParent().args
	local retval = capiunto.create( {
		title = args.name,
	} )

	retval:addImage( args.image, args.imagecaption )
	if v(args.aliases) then retval:addRow( 'Aliases', args.aliases ) end
	if v(args.relatives) then retval:addRow( 'Relatives', args.relatives ) end
	if v(args.other) then retval:addRow( 'Other', args.other ) end
	if v(args.affiliation) then retval:addRow( 'Affiliation', args.affiliation ) end
	if v(args.occupation) then retval:addRow( 'Occupation', args.occupation ) end

	if v(args.status) or v(args.marital) or v(args.age) or v(args.birthDate) or v(args.birthPlace) or v(args.deathDate) or v(args.deathPlace) then
		retval:addHeader( 'Biographical information' )
		if v(args.status) then retval:addRow( 'Status', args.status ) end
		if v(args.marital) then retval:addRow( 'Marital Status', args.marital ) end
		if v(args.age) then retval:addRow( 'Age', args.age ) end
		if v(args.birthDate) then retval:addRow( 'Date of birth', args.birthDate ) end
		if v(args.birthPlace) then retval:addRow( 'Place of birth', args.birthPlace ) end
		if v(args.deathDate) then retval:addRow( 'Date of death', args.deathDate ) end
		if v(args.deathPlace) then retval:addRow( 'Place of death', args.deathPlace ) end
	end
	
	if v(args.species) or v(args.gender) or v(args.height) or v(args.weight) or v(args.eyes) then
		retval:addHeader( 'Physical description' )
		if v(args.species) then retval:addRow( 'Species', args.species ) end
		if v(args.gender) then retval:addRow( 'Gender', args.gender ) end
		if v(args.height) then retval:addRow( 'Height', args.height ) end
		if v(args.weight) then retval:addRow( 'Weight', args.weight ) end
		if v(args.eyes) then retval:addRow( 'Eye Color', args.eyes ) end
	end
	
	if v(args.crimes) or v(args.equiment) then
		retval:addHeader( 'General Information' )
		if v(args.crimes) then retval:addRow( 'Crime(s)', args.crimes ) end
		if v(args.equipment) then retval:addRow( 'Equipment', args.equipment ) end
	end

	return retval
end

return p