Minecraft Wiki

除另有声明,转载时均必须注明出处若簡繁轉換出錯,請以遊戲內為準请勇于扩充与修正内容有兴趣逛逛我们的微博沟通交流,欢迎到社区专页需要协助,请在告示板留言

了解更多

Minecraft Wiki
注册
Advertisement
[创建 | 历史 | 清除缓存]文档页面
此模块没有文档页面。如果你知道此模块的使用方法,请帮助为其创建文档页面。
local p = {}

local i18n = {
	categorySuffix = '配方',
	typeMap = {
		['brewing'] = '酿造',
		['building block'] = '建筑方块',
		['combat'] = '战斗',
		['decoration block'] = '装饰性方块',
		['foodstuff'] = '食物',
		['material'] = '原材料',
		['miscellaneous'] = '杂项',
		['redstone'] = '红石',
		['tool'] = '工具',
		['transportation'] = '交通',
	}
}

function p.type( f )
	local args = f.args
	local crafting = require( [[Module:Crafting]] ).table
	local type = mw.text.trim( args[1] )

	local argList = {
		'type', 'upcoming', 'name', 'ingredients', 'arggroups',
		1, 2, 3, 4, 5, 6, 7, 8, 9,
		'A1', 'B1', 'C1', 'A2', 'B2', 'C2', 'A3', 'B3', 'C3',
		'Output', 'description', 'fixed', 'notfixed',
		'A1title', 'A1link', 'B1title', 'B1link', 'C1title', 'C1link',
		'A2title', 'A2link', 'B2title', 'B2link', 'C2title', 'C2link',
		'A3title', 'A3link', 'B3title', 'B3link', 'C3title', 'C3link',
		'Otitle', 'Olink',
	}
	
	local data = f:callParserFunction( '#dpl:', {
		category = ( i18n.typeMap[type:lower()] or type ) .. i18n.categorySuffix,
		include = '{Crafting}:' .. table.concat( argList, ':' ),
		mode = 'userformat',
		secseparators = '====',
		multisecseparators = '===='
	} )
	
	local out = {}
	local showDesciption
	local templates = {}
	for template in mw.text.gsplit( data, '====' ) do
		-- If type matches
		if template:find( '^%s*' .. type .. '%s*|' ) then
			local tArgs = {}
			local i = 0
			-- Extract the arguments from the DPL query
			for tArg in mw.text.gsplit( template, '\n|' ) do
				i = i + 1
				if tArg ~= '' then
					local key = argList[i]
					tArgs[key] = tArg
				end
			end
			
			if tArgs.description then
				showDescription = true
			end
			
			tArgs.nocat = '1'
			
			table.insert( templates, tArgs )
		end
	end
	if #templates == 0 then
		return
	end
	
	templates[1].head = '1'
	templates[1].showname = '1'
	if showDescription and args.showdesciption ~= '0' or args.showdesciption == '1' then
		templates[1].showdescription = '1'
	end
	if not args.continue then
		templates[#templates].foot = '1'
	end
	
	local out = {}
	for i, v in ipairs( templates ) do
		table.insert( out, crafting( v ) )
	end
	
	return table.concat( out, '\n' )
end
return p
Advertisement