Module:Sandbox

MDFW - The Mystery Dungeon Tree of Information.
Revision as of 22:10, 24 March 2023 by Adkuate (talk | contribs)
Jump to navigation Jump to search



----------------------------------------------------------------------------------------------------
--
--                                        Module:Sandbox
--
-- Here you can set anything you want in this sandbox, as long as it uses the language Lua.
-- Do not forget to add {{#invoke:Sandbox|<function name>}} in your template.
-- [[Category:Sandbox]]
--
----------------------------------------------------------------------------------------------------

local p = {}

function p.main(frame)
    local args = frame.args
    local rows = tonumber(args.rows) or 0
    local cols = tonumber(args.cols) or 0
    local table_class = args.class or "wikitable"
    local output = "{| class=\"" .. table_class .. "\"\n"
    -- Header row
    output = output .. "|-\n"
    for j = 1, cols do
        output = output .. "! " .. (args["h" .. j] or "") .. "\n"
    end
    -- Data rows
    for i = 1, rows do
        output = output .. "|-\n"
        for j = 1, cols do
            output = output .. "| " .. (args[i .. "_" .. j] or "") .. "\n"
        end
    end
    output = output .. "|}\n"
    return output
end

return p