Module:Infobox character: Difference between revisions

From Sekaipedia
Content added Content deleted
(created infobox for characters)
 
mNo edit summary
Line 82: Line 82:
{ hideIfEmpty = { 'english' } }
{ hideIfEmpty = { 'english' } }
)
)
:addHeader({ tag = 'th', content = 'Logo'})
:addHeader({ tag = 'th', content = 'Unit'})
:addImage{{ tag = 'argtd', content = 'unit' }}
:addImage{{ tag = 'argtd', content = 'unit' }}
:addRow(
:addRow(

Revision as of 06:29, 2 July 2021

To generate {{Infobox character}}, invoke using the main function.


--------------------------
-- Module for [[Template:Infobox Character]]
------------------------
local builder = require('Module:InfoboxBuilder')

local p = {}
local categories = ""

local function formatImage(image_name)
	return string.format("[[File:%s|300px]]", image_name)
end

local function formatUnit(unit)
	local units = {
		vs       = { image = 'Virtualsingerlogo.png', link = 'VIRTUAL SINGER' },
		ln       = { image = 'Leoneedlogo.png', link = 'Leo/need' },
		mmj      = { image = 'MMJ_logo.png', link = 'MORE MORE JUMP!'},
		vbs      = { image = 'Vivid_logo.png', link = 'Vivid BAD SQUAD'},
		wxs      = { image = 'Wonderlandsxswowtimelogo.png', link = 'Wonderlands×Showtime' },
		['25ji'] = { image = '25ji-logo.png', link = '25-ji, Night Code de.' }
	}
	
	if units[unit] then
		return string.format("[[File:%s|150px|link=%s]]",
			units[unit].image,
			units[unit].link)
	end
	
	return nil
end


function p.main(frame)
	local args = frame:getParent().args
	local infobox = builder.new();
	
	infobox:setName('Infobox Group')
		:setWidth("330px")
	infobox:setParams{
		{ name = 'character name', default = mw.title.getCurrentTitle().text },
		{ name = 'character image', func = formatImage },
		{ name = 'japanese' },
		{ name = 'romaji' },
		{ name = 'english' },
		{ name = 'unit', func = formatUnit },
		{ name = 'position' },
		{ name = 'gender' },
		{ name = 'birthday' },
		{ name = 'height' },
		{ name = 'school' },
		{ name = 'hobbies' },
		{ name = 'talents' },
		{ name = 'dislikes' },
		{ name = 'seiyuu' }
	}
	
	infobox
		:setArgs(args)

	infobox
		:addHeader({ tag = 'argth', content = 'character name' })
		:addImage{{ tag = 'argtd', content = 'character image' }}
		:addRow(
			{
				{ tag = 'th', content = 'Japanese', colspan = 12 },
				{ tag = 'argtd', content = 'japanese', colspan = 18 }
			},
			{ hideIfEmpty = { 'japanese' } }
		)
		:addRow(
			{
				{ tag = 'th', content = 'Romaji', colspan = 12 },
				{ tag = 'argtd', content = 'romaji', colspan = 18 }
			},
			{ hideIfEmpty = { 'romaji' } }
		)
		:addRow(
			{
				{ tag = 'th', content = 'English', colspan = 12 },
				{ tag = 'argtd', content = 'english', colspan = 18 }
			},
			{ hideIfEmpty = { 'english' } }
		)
		:addHeader({ tag = 'th', content = 'Unit'})
		:addImage{{ tag = 'argtd', content = 'unit' }}
		:addRow(
			{
				{ tag = 'th', content = 'Position', colspan = 12 },
				{ tag = 'argtd', content = 'position', colspan = 18 }
			},
			{ hideIfEmpty = { 'position' } }
		)
		:addHeader({ tag = 'th', content = 'Profile' })
		:addRow(
			{
				{ tag = 'th', content = 'Gender', colspan = 12 },
				{ tag = 'argtd', content = 'gender', colspan = 18 }
			}
		)
		:addRow(
			{
				{ tag = 'th', content = 'Birthday', colspan = 12 },
				{ tag = 'argtd', content = 'birthday', colspan = 18 }
			}
		)
		:addRow(
			{
				{ tag = 'th', content = 'Height', colspan = 12 },
				{ tag = 'argtd', content = 'height', colspan = 18 }
			}
		)
		:addRow(
			{
				{ tag = 'th', content = 'School', colspan = 12 },
				{ tag = 'argtd', content = 'school', colspan = 18 }
			},
			{ hideIfEmpty = { 'school' } }
		)
		:addRow(
			{
				{ tag = 'th', content = 'Hobbies', colspan = 12 },
				{ tag = 'argtd', content = 'hobbies', colspan = 18 }
			},
			{ hideIfEmpty = { 'hobbies' } }
		)
		:addRow(
			{
				{ tag = 'th', content = 'Talents', colspan = 12 },
				{ tag = 'argtd', content = 'talents', colspan = 18 }
			},
			{ hideIfEmpty = { 'talents' } }
		)
		:addRow(
			{
				{ tag = 'th', content = 'Dislikes', colspan = 12 },
				{ tag = 'argtd', content = 'dislikes', colspan = 18 }
			},
			{ hideIfEmpty = { 'dislikes' } }
		)
		:addRow(
			{
				{ tag = 'th', content = 'Image Color', colspan = 12 },
				{ tag = 'argtd', content = 'bg color', colspan = 18 }
			}
		)
		:addRow(
			{
				{ tag = 'th', content = 'Seiyuu', colspan = 12 },
				{ tag = 'argtd', content = 'seiyuu', colspan = 18 }
			}
		)
		
	if mw.title.getCurrentTitle().namespace == 0 then
		categories = "[[Category:Characters]]" .. categories
	end

	return infobox:tostring() .. categories
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.