Module:ModuleUniqueStatTable: Difference between revisions

From The First Descendant Wiki
No edit summary
No edit summary
Line 39: Line 39:
     local result = "Name: " .. name .. name .. name .. ", Property2: " .. property2
     local result = "Name: " .. name .. name .. name .. ", Property2: " .. property2
      
      
     return frame.args[0]
     return frame.args.csv
end
end


return p
return p

Revision as of 06:04, 5 June 2024

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

local p = {}

function parseCSV(csv)
    local result = {}
    local cell = ""
    local inQuotes = false

    for i = 1, #csv do
        local char = csv:sub(i, i)
        
        if char == '"' then
            inQuotes = not inQuotes
        elseif char == '@' and not inQuotes then
            table.insert(result, cell)
            cell = ""
        elseif char == '\n' and not inQuotes then
            table.insert(result, cell)
            cell = ""
        else
            cell = cell .. char
        end
    end

    if cell == "" then
        cell = "Q"
    end

    table.insert(result, cell)

    return result
end

function p.processData(frame)
    local property1 = frame.args.property1 or ""
    local property2 = frame.args.property2 or ""
    local name = frame.args.name or "DNE"
    
    -- Process the data
    local result = "Name: " .. name .. name .. name .. ", Property2: " .. property2
    
    return frame.args.csv
end

return p