跳转到内容

模組:機動兵器

维基百科,自由的百科全书

这是本页的一个历史版本,由Cwek留言 | 贡献2024年9月3日 (二) 04:30 建立内容为“local p ={} local infoboxFunc local getArgs local argsIndex = 1 function partFunc2(index, origArgs, outputArgs, labelVF , ...) local prefix = index == 1 and '' or tostring(index) if labelVF == 'above' or labelVF == 'header' then outputArgs[labelVF == 'above' and 'above' or ('header' .. argsIndex) ] = args[1] argsIndex = argsIndex + 1 else local key1,key2 local val1,val2 key1 = 'label' .. argsIndex key2 = 'data' .. argsIndex…”的新页面)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)
local p ={}
local infoboxFunc
local getArgs 
local argsIndex = 1

function partFunc2(index, origArgs, outputArgs, labelVF , ...)
	local prefix = index == 1 and  '' or tostring(index)
	if labelVF == 'above' or labelVF == 'header' then
		outputArgs[labelVF == 'above' and 'above' or ('header' .. argsIndex) ] = args[1]
		argsIndex = argsIndex + 1 
	else
		local key1,key2
		local val1,val2
		key1 = 'label' .. argsIndex
		key2 = 'data' .. argsIndex
		argsIndex = argsIndex + 1 
		
		local lengthArgs=#args
		local argPick = ''
		for i=lengthArgs,1,-1 do
			val2 = origArgs[ prefix .. args[i] ]
		end
		-- TODO
		if type(labelVF) == 'string' then
			val1 = labelVF
		elseif type(labelVF) == 'function' then
			val1 = labelVF(prefix)
		end
		
		outputArgs[key1]=val1
		outputArgs[key2]=val2
	end
end

function partFunc(index,origArgs,outputArgs)
	local prefix = index == 1 and  '' or tostring(index)
	
	local name = origArgs[prefix .. '名称']
	local must = (index == 1 or name ~= '')
	if must then
		local name2 
		if origArgs[prefix..'正式名称'] ~='' then
			name2 = name 
		else 
			name2 = name .. '<br/>' .. origArgs[prefix..'正式名称']
		end
		partFunc2(index, origArgs, outputArgs, index == 1 and 'above' or 'header' , name2)
		--
		partFunc2(index, origArgs, outputArgs, prefix..'別稱', '別稱')
		
		
	end
end


function p.main()
	if not getArgs then getArgs = require('Module:Arguments').getArgs end	
	if not infoboxFunc then infoboxFunc = require('Module:Infobox').infobox end	
	
	local origArgs = getArgs(frame, { trim = true})
	
	local args = {}
	args['templatestyles']='Module:Infobox/bordered/styles.css'
	args['bodyclass']='bordered'
	args['bodystyle']='clear:both; font-size:12px;'
	args['title']='規格'
	
	if origArgs['圖片'] then
		local InfoboxImage = require('Module:InfoboxImage').InfoboxImage 
		args['image'] = InfoboxImage{
				['image']=origArgs['圖片'],
				['alt']=origArgs['描述'],
				['class']='skin-invert'
			}
		args['caption']=origArgs['描述']
	end
	
	for i=1,5 do
		partFunc(i,origArgs,args)
	end
	
	return tostring(infoboxFunc(args))
end

return p