Module:GameChapterInfo

From Little Tail Wiki
Revision as of 20:43, 2 March 2025 by Zoltier (talk | contribs) (Created page with "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 = args.title, headerStyle = hea...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
Chapter title

Chapter image (IMAGE REQUIRED)
Info.
Japanese name Optional
Romanized name Optional
Location Optional
Namesake Optional
Boss Optional
Previous chapter Optional
Next chapter Optional


The GameChapterInfo infobox lists basic facts about the article's featured video game chapter.

Infoboxes are put together via Capiunto, which calls upon a Lua-based module. This keeps infoboxes clean and easy to form.

In source editor, excluding any optional row will make that row not render. Leaving out any required fields will throw an error over the page. HTML tags can be used within the infobox if necessary.

Specific rows

  • Japanese name: The book's original title in Japanese
  • Romanized name: The book's Japanese title romanized
  • Location: The primary location the chapter takes place in
  • Namesake: What the chapter is named after
  • Boss: The boss fought in this chapter

Usage

{{GameChapterInfo
| title       = Chapter title
| headerstyle = (defaults to background-color:grey)
| image       = [[File:Unknown.png|200px]]
| caption     =  Chapter image (IMAGE REQUIRED)
| ("Info.")
| ja_kanji = Optional
| ja_romaji = Optional
| location = Optional
| namesake = Optional
| boss = Optional
| prev_chap = Optional
| next_chap = 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 = args.title,
        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 = {
        { 'Japanese name', args.ja_kanji },
        { 'Romanized name', args.ja_romaji },
        { 'Location', args.location },
        { 'Namesake', args.namesake },
        { 'Boss', args.boss },
        { 'Previous chapter', args.prev_chap },
        { 'Next chapter', args.next_chap },

    }

    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