Module:Version

From Minecraft Wiki
Jump to: navigation, search
[view | edit | history | purge]DocumentationJump to code ↴

NOTE: The usage of this template is deprecated. Please use {{version}} instead.

[view | edit | history | purge]The above documentation is transcluded from Module:Version/doc.
local p = {}
p.version = function( f )
	local args = f:getParent().args
	local versions = mw.loadData( 'Module:Version/Numbers' )
	local version = 'pc'
	if args.c then
		args.classic = '1'
	end
	for v in pairs( args ) do
		if type( v ) == 'string' then
			v = v:lower()
			if versions[v] then
				version = v
				break
			end
		end
	end
	
	local edition
	if args.s or args.server then
		edition = versions[version .. '-server']
	end
	if not edition then
		edition = versions[version]
	end
	local versionNum = edition[1] or edition
	local prefix = edition.prefix or ''
	
	local style = ''
	if args[1] then
		style = f:expandTemplate{ title = 'Table Choice', args = { args[1] == versionNum and 'yes' or 'no', '' } }
	end
	
	if args.nolink or versionNum == '' then
		return style .. ( args[1] or versionNum )
	else
		return style .. f:expandTemplate{ title = 'Version link', args = {
			prefix .. ' ' .. ( args[1] or versionNum ),
			args[2] or args[1] or versionNum
		} }
	end
end
return p