Módulo:Versión

De WikiMinecraft
Saltar a: navegación, buscar
Documentation for this module may be created at Módulo:Versión/doc
local p = {}
p.version = function( f )
	local args = f:getParent().args
	local versions = mw.loadData( 'Módulo:Versión/Números' )
	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