Module:History
From Vintage Story Wiki
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')
local body = table.concat(header, '\n') .. '\n'
for k1,v1 in pairs(versions) do
body = body .. '|[[' .. k1 .. ']]'
for k2,v2 in pairs(v1) do
body = body .. '||[[' .. k2 .. ']]||' .. v2
end
end
return body .. '\n' .. footer
end
return p