Module:FrameData

From ARMS Institute, the ARMS Wiki
Jump to navigation Jump to search

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

local getArgs = require( 'Module:Arguments' ).main
local p = {}
local columntotal = {
    ["BEAM"] = "18",
    ["HEAD"] = "18",
    ["MULTI"] = "18"
}
local standardcolumn = "6"

function p.totalcolumns(frame)
    local args = getArgs(frame)
    local type = string.upper(args[1])
    local output
    for key, value in pairs(columntotal) do
        if string.match(type, key) then
            output = type:gsub(key, value)
            return output
        else
            return standardcolumn
        end
    end
end

function p.headercell(frame)
    local args = getArgs(frame)
    local type = string.upper(args[1])
    local output
    for key, value in pairs(columntotal) do
        if string.match(type, key) then
            if type == "MULTI" then
                output = type:gsub(key, value)
                output = tonumber(output) / 9
                return output
            else
                output = type:gsub(key, value)
                output = tonumber(output) / 3
                return output
            end
        else
            return tonumber(standardcolumn) / 3
        end
    end
end

return p