Module:Character: Difference between revisions

From The Coffin of Andy and Leyley

No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 4: Line 4:


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


function p.main(frame)
function p.main(frame)
Line 14: Line 13:
} )
} )


retval:addImage( args.image, args.imagecaption )
retval:addImage( args.image, args.imagecaption )
if v(args.aliases) then retval:addRow( 'Aliases', args.aliases ) end
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.relatives) then retval:addRow( 'Relatives', args.relatives ) end
if v(args.other) then retval:addRow( 'Other', args.other ) end
if v(args.other) then retval:addRow( 'Other', args.other ) end
if v(args.affilication) then retval:addRow( 'Affiliation', args.affilication ) 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.occupation) then retval:addRow( 'Occupation', args.occupation ) end
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
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
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


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
return retval

Latest revision as of 03:55, 1 January 2024

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' and val ~= '') 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