Module:History: Difference between revisions
From Vintage Story Wiki
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function newAutotable(dim) | |||
local MT = {}; | |||
for i=1, dim do | |||
MT[i] = {__index = function(t, k) | |||
if i < dim then | |||
t[k] = setmetatable({}, MT[i+1]) | |||
return t[k]; | |||
end | |||
end} | |||
end | |||
return setmetatable({}, MT[1]); | |||
end | |||
function p.create(f) | function p.create(f) | ||
Line 11: | Line 25: | ||
local footer = '|}' | local footer = '|}' | ||
local versions = newAutotable(2) | |||
local versions = | |||
for i,v in pairs(args) do | for i,v in pairs(args) do | ||
local version = string.match(v, '(.*);') | local version = string.match(v, '(.*);') |
Revision as of 17:41, 27 August 2022
Documentation for this module may be created at Module:History/doc
local p = {}
function newAutotable(dim)
local MT = {};
for i=1, dim do
MT[i] = {__index = function(t, k)
if i < dim then
t[k] = setmetatable({}, MT[i+1])
return t[k];
end
end}
end
return setmetatable({}, MT[1]);
end
function p.create(f)
local args = require( 'Module:ProcessArgs' ).merge( true )
local header = {
'{|class="wikitable"',
'!colspan="3"|History',
'|-'
}
local footer = '|}'
local versions = newAutotable(2)
for i,v in pairs(args) do
local version = string.match(v, '(.*);')
local parent = string.match(version, '(.*)-')
local child = string.match(version, '-(.*)')
local note = string.match(v , ';(.*)')
versions[parent][child] = note
end
local body = table.concat(header, '\n')
for ver in ipairs(versions) do
body = body .. '|[[' .. tostring(ver) .. ']]'
for child in ipairs(ver) do
body = body .. '||[[' .. tostring(child) .. ']]'
for note in ipairs(child) do
body = body .. '||' .. note
end
end
end
return body .. '\n' .. footer
end
return p