Module:GameInfo
From Little Tail Wiki
The GameInfo infobox serves as a quick rundown of the article's featured videogame.
Infoboxes are put together via Capiunto, which calls upon a Lua-based module. This keeps infoboxes clean and easy to form as long as anything marked as required is filled. Failure to fill what's required will throw an error over the page.
Usage
{{GameInfo | headerstyle = (defaults to background-color:grey) | image = [[File:TailConcerto Logo.png|200px]] | caption = Tail Concerto logo (IMAGE REQUIRED) | ("Info.") | developers = Optional | publishers = Optional | directors = Optional | producers = Optional | designers = Optional | artists = Optional | writers = Optional | composers = Optional | platforms = Optional | genre = Optional | numplayers = Optional | rating = Optional | releasedates = Optional | website = Optional }}
local capiunto = require 'capiunto'
local p = {}
function p.main(frame)
local args = frame:getParent().args
-- Set header style, defaulting to 'background-color:grey' if not provided
local headerStyle = args.headerstyle and args.headerstyle ~= '' and
string.format('background-color:%s;', args.headerstyle) or 'background-color:grey;'
-- Create the infobox
local retval = capiunto.create({
title = tostring(mw.title.getCurrentTitle()),
headerStyle = headerStyle,
})
-- Add image and caption
if args.image then
retval:addImage(args.image, args.caption or '')
end
-- Add a general header
retval:addHeader('Info.')
-- Add rows only for fields that are not empty
local rows = {
{ 'Developer(s)', args.developer },
{ 'Publisher(s)', args.punblisher },
{ 'Producer(s)', args.producers },
{ 'Director(s)', args.directors },
{ 'Designer(s)', args.designers },
{ 'Artist(s)', args.artists },
{ 'Writer(s)', args.writers },
{ 'Composer(s)', args.composers },
{ 'Platform(s)', args.platforms },
{ 'Genre', args.genre },
{ 'Number of Players', args.numplayers },
{ 'Rating', args.rating },
{ 'Release Date(s)', args.releasedates },
{ 'Website', args.website },
}
for _, row in ipairs(rows) do
local label, value = row[1], row[2]
if value and value ~= '' then
retval:addRow(label, value)
end
end
return retval
end
return p