Module:Sandbox: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
(Replaced content with "---------------------------------------------------------------------------------------------------- -- -- 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...")
Tag: Replaced
mNo edit summary
Tag: Reverted
Line 11: Line 11:
local p = {}
local p = {}


function p.main(frame)
function p.main(args)
    local args = frame.args
     local output = '{| class="wikitable"\n'
    local rows = tonumber(args.rows) or 0
     output = output .. '! Column 1 !! Column 2\n'
    local cols = tonumber(args.cols) or 0
     for i, item in ipairs(args) do
    local table_class = args.class or "wikitable"
         output = output .. '|-\n| ' .. item .. ' || ' .. i .. '\n'
     local output = "{| class=\"" .. table_class .. "\"\n"
    -- Header row
     output = output .. "|-\n"
     for j = 1, cols do
         output = output .. "! " .. (args["h" .. j] or "") .. "\n"
     end
     end
    -- Data rows
     output = output .. '|}\n'
    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
     return output
end
end


return p
return p

Revision as of 21:52, 24 March 2023



----------------------------------------------------------------------------------------------------
--
--                                        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(args)
    local output = '{| class="wikitable"\n'
    output = output .. '! Column 1 !! Column 2\n'
    for i, item in ipairs(args) do
        output = output .. '|-\n| ' .. item .. ' || ' .. i .. '\n'
    end
    output = output .. '|}\n'
    return output
end

return p