Module:Table/Wrench
From Growtopia
Documentation for this module may be created at Module:Table/Wrench/doc
local p = {}
function p.build_table(frame)
local args = frame:getParent().args
local data = args['data'] or ''
if args == '' then
return ''
end
local lines = mw.text.split(data, "\n")
local results = {}
for _, line in ipairs(lines) do
line = mw.text.trim(line)
if line ~= "" then
line = line:gsub("%s*%$%$%$", "")
local parts = mw.text.split(line, "|")
local month = parts[1] or ""
local item = parts[2] or ""
-- 4. Insert into a Lua table
table.insert(results, {
month = mw.text.trim(month),
item = mw.text.trim(item),
})
end
end
local output = {}
for _, row in ipairs(results) do
table.insert(output, "* " .. row.month .. " | [[" .. row.item .. "]]\n")
end
return table.concat(output)
end
return p