Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Deck Layout

From Vault Hunters Official Wiki
Revision as of 18:58, 11 July 2025 by Mnooseman (talk | contribs) (Created page with "local p = {} function p.render(frame) local layout = frame.args.layout or "" local rows = mw.text.split(layout, "\n") local output = {} local rowCount = #rows local colCount = 0 for _, row in ipairs(rows) do colCount = math.max(colCount, mw.ustring.len(row)) end -- Top row table.insert(output, "|-") for c = 0, colCount + 1 do local cls = "border-top" if c == 0 then cls = "corner-tl" elseif c == co...")
(diff) ← Older revision | Latest revision (diff) | Newer revision β†’ (diff)

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

local p = {}

function p.render(frame)
    local layout = frame.args.layout or ""
    local rows = mw.text.split(layout, "\n")
    local output = {}

    local rowCount = #rows
    local colCount = 0
    for _, row in ipairs(rows) do
        colCount = math.max(colCount, mw.ustring.len(row))
    end

    -- Top row
    table.insert(output, "|-")
    for c = 0, colCount + 1 do
        local cls = "border-top"
        if c == 0 then cls = "corner-tl"
        elseif c == colCount + 1 then cls = "corner-tr" end
        table.insert(output, string.format('| class="%s" |', cls))
    end

    -- Middle rows
    for r = 1, rowCount do
        local row = rows[r]
        table.insert(output, "|-")

        -- Left border
        table.insert(output, '| class="border-left" |')

        for c = 1, colCount do
            local cell = row:sub(c, c)
            local class = "center"
            if cell == "O" then
                class = "slot-free"
            elseif cell == "X" then
                class = "slot-disabled"
            end
            table.insert(output, string.format('| class="%s" |', class))
        end

        -- Right border
        table.insert(output, '| class="border-right" |')
    end

    -- Bottom row
    table.insert(output, "|-")
    for c = 0, colCount + 1 do
        local cls = "border-bottom"
        if c == 0 then cls = "corner-bl"
        elseif c == colCount + 1 then cls = "corner-br" end
        table.insert(output, string.format('| class="%s" |', cls))
    end

    return table.concat(output, "\n")
end

return p