Module:Akitem

From Moegirlpedia
Jump to: navigation, search
Template-info.svg Module Documentation  [View] [Edit] [History] [Refresh]

This module implements the functionality of {{Akitem}}. Please do not invoke this module directly.

-- Module:Akitem
-- Made with ♥ by User:Leranjun

-- This module implements {{tl|Akitem}}.
-- Please refrain from invoking this module directly.

local p = {}

local getArgs = require("Module:Arguments").getArgs

local function notempty(s)
    return (s and s ~= "")
end

function p.main(frame)
    return p._main(getArgs(frame), frame)
end

function p._main(args, frame)
    if (not notempty(args[2])) then
        error("Akitem 错误:参数 2 不能为空")
    end

    local t = mw.ustring.lower(args[1])

    frame = frame or mw.getCurrentFrame()

    if (t == "mat") then
        return frame:expandTemplate {
            title = "akmat",
            args = {
                args[2],
                size = args.size or 75,
                unit = args.unit or "px",
                num = args.num,
                size2 = args.size2 or "11.2pt",
                dt = args.dt,
                link = args.link
            }
        }
    elseif (t == "skin") then
        return frame:expandTemplate {
            title = "akskin",
            args = {
                args[2],
                args[3],
                size = args.size or args[4] or 75,
                unit = args.unit or "px",
                isnav = args.isnav
            }
        }
    elseif (t == "con") then
        return frame:expandTemplate {
            title = "akcon",
            args = {
                args[2],
                args[3],
                size = args.size or args[4] or 75,
                unit = args.unit or "px",
                dt = args.dt
            }
        }
    elseif (t == "fur") then
        return frame:expandTemplate {
            title = "akfurni",
            args = {
                args[2],
                args.size or args[3] or 75,
                unit = args.unit or "px",
                dt = args.dt
            }
        }
    else
        error("Akitem error: Illegal pattern code. Please check if parameter 1 is one of mat, skin, con, or fur ")
    end
end

return p