Module:Table/Wrench: Difference between revisions
From Growtopia
Jump to navigationJump to search
>HashJona mNo edit summary |
>HashJona mNo edit summary |
||
| Line 31: | Line 31: | ||
local output = {} | local output = {} | ||
for _, row in ipairs(results) do | for _, row in ipairs(results) do | ||
table.insert(output, " | table.insert(output, "\n|-\n|" .. row.month .. "|" .. row.item) | ||
end | end | ||
Revision as of 06:56, 5 April 2025
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, "\n|-\n|" .. row.month .. "|" .. row.item)
end
return table.concat(output)
end
return p