There are no reviewed versions of this page, so it may not have been checked for adherence to standards.

Documentation for this module may be created at Module:Test13/doc

local p = {}
function p.main(frame)
    local text = ""
    for k, val in pairs(frame) do
        text = text .. "* pair " .. k .. ", " .. tostring(val) .. "\n"
    end
    for k, val in frame:argumentPairs() do
        text = text .. "* argument (" .. type(k) .. ") " .. k .. " = '" .. val .. "'\n"
    end
    return text
end

function p.ship(frame)
    -- emulate [[Template:Ship]] on enwiki
    local shiptext = {}
    local arg1 = frame.args[1] or ""
    local arg2 = frame.args[2] or ""
    local arg3 = frame.args[3] or ""
    local arg4 = frame.args[4]
    if frame.args.up ~= nil then 
        table.insert(shiptext, arg1 .. " ")
    end 
    table.insert(shiptext, "[[" .. arg1 .. " " .. arg2)
    if arg3 ~= "" then 
        table.insert(shiptext, " (" .. arg3 .. ")")
    end
    table.insert(shiptext, "|")
    if arg4 == "1" then 
        if arg3 ~= "" then 
            table.insert(shiptext, arg3)
        else 
            table.insert(shiptext, "Hull Number Missing")
        end
    elseif arg4 == "2" then 
        table.insert(shiptext, "''" .. arg2 .. "''")
    elseif arg4 == "3" then 
        table.insert(shiptext, "''" .. arg2 .. "'' ")
        if arg3 ~= "" then 
            table.insert(shiptext, " (" .. arg3 .. ")")
        else 
            table.insert(shiptext, "Hull Number Missing")
        end
    elseif arg4 == "4" then 
        table.insert(shiptext, "Invalid Optional Parameter")
    elseif arg4 == "5" then 
        table.insert(shiptext, arg1 .. " ")
        if arg3 ~= "" then 
            table.insert(shiptext, " (" .. arg3 .. ")")
        else 
            table.insert(shiptext, "Hull Number Missing")
        end
    elseif arg4 == "6" then
        table.insert(shiptext, arg1 .. " ''" .. arg2 .. "''")
    else
        table.insert(shiptext, arg1 .. " ''" .. arg2 .. "''")
        if arg3 ~= "" then 
            table.insert(shiptext, " (" .. arg3 .. ")")
        end
    end
    table.insert(shiptext, "]]")
    --[=[ original template code: <nowiki>
{{safesubst:#if:{{{up|}}}
| {{{1}}}&#32;
}}[[{{{1}}} {{{2}}}{{safesubst:#if:{{{3|}}}| &#32;({{{3}}})}}|{{safesubst:#switch:{{{4|7}}}
|1 = {{safesubst:#if:{{{3|}}}|{{{3}}}|Hull Number Missing}}
|2 = ''{{{2}}}''
|3 = ''{{{2}}}''&nbsp;{{safesubst:#if:{{{3|}}}|({{{3}}})|Hull Number Missing}}
|4 = Invalid Optional Parameter
|5 = {{{1}}}&nbsp;{{safesubst:#if:{{{3|}}}|({{{3}}})|Hull Number Missing}}
|6 = {{{1}}}&nbsp;''{{{2}}}''
| {{{1}}}&nbsp;''{{{2}}}''{{safesubst:#if:{{{3|}}}|&nbsp;({{{3}}})}}
}}]]
    </nowiki> ]=]
    return table.concat(shiptext)
end

function p.infinite(frame)
    local a = 1
    while true do
        a = a + 1
    end
    return a
end

return p