Module:ModuleLevelTable

From The First Descendant Wiki
Revision as of 03:18, 4 June 2024 by Software2 (talk | contribs)

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

local p = {}

function p.parseCSV(input)
    local array = {}
    local i = 1
    
    -- Split the input by lines
    for line in mw.text.split(input, "\n") do
        array[i] = {}
        local j = 1
        
        -- Split each line by commas
        for cell in mw.text.split(line, ",") do
            array[i][j] = mw.text.trim(cell)
            j = j + 1
        end
        
        i = i + 1
    end
    
    return array
end

function p.getTable(input)
    local array = p.parseCSV(input)
    return array[1][1]
end

return p