Module:ModuleUniqueStatTable: Difference between revisions

From The First Descendant Wiki
No edit summary
No edit summary
Line 1: Line 1:
local p = {}
local p = {}


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


     for i = 1, #csv do
function split(str)
        local char = csv:sub(i, i)
     splitArray = {}
       
    for match in (str.."@"):gmatch("(.-)"..sep) do
        if char == '"' then
         table.insert(splitArray, match)
            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
     end
end


     if cell == "" then
function p.processData(frame)
         cell = "Q"
     if frame.args.csv == nil then
         return "ERROR: Module:ModuleUniqueStatTable got no csv string! Please tell us on Discord!"
     end
     end
    split(frame.args.csv)


     table.insert(result, cell)
     local result = ""
 
    for i, part in ipairs(parts) do
        result = result .. "####" .. part
    end
     return result
     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
end


return p
return p

Revision as of 06:12, 5 June 2024

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

local p = {}

local splitArray = {}

function split(str)
    splitArray = {}
    for match in (str.."@"):gmatch("(.-)"..sep) do
        table.insert(splitArray, match)
    end
end

function p.processData(frame)
    if frame.args.csv == nil then
        return "ERROR: Module:ModuleUniqueStatTable got no csv string! Please tell us on Discord!"
    end
    split(frame.args.csv)

    local result = ""
    for i, part in ipairs(parts) do
        result = result .. "####" .. part
    end
    return result
end

return p