Module:History: Difference between revisions

From Vintage Story Wiki
mNo edit summary
mNo edit summary
Line 16: Line 16:
for i,v in pairs(args) do
for i,v in pairs(args) do
local version = string.match(v, '(.*);')
local version = string.match(v, '(.*);')
local parentVer = string.match(version, '(.*)-')
local parent = string.match(version, '(.*)-')
local childVer = string.match(version, '-(.*)')
local child = string.match(version, '-(.*)')
local note = string.match(v , ';(.*)')
local note = string.match(v , ';(.*)')
versions[parent][child] = note
versions[parentVer][childVer] = note
end
end

Revision as of 17:22, 27 August 2022

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

local p = {}

function p.create(f)
	local args = require( 'Module:ProcessArgs' ).merge( true )
		
	local header = {
		'{|class="wikitable"',
		'!colspan="3"|History',
		'|-'
	}
	local footer = '|}'
	
	local notes = {}
	local versions = {}
	local parentVer = {}
	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 = header .. '\n'
	for ver in versions do
		body = body .. '|[[' .. tostring(ver) .. ']]'
		for child in ver do
			body = body .. '||[[' .. tostring(child) .. ']]'
			for note in child do 
				body = body .. '||' .. note	
			end
		end
	end
	return body .. '\n' .. footer
end
return p