Minecraft Wiki
Advertisement
[создать | история | обновить]Документация
У этого модуля нет документации. Если вы знаете, как использовать этот модуль, пожалуйста, добавьте соответствующую информацию.
local p = {}
function p.type( f )
	local args = f.args
	local crafting = require( 'Модуль:Крафт' ).table
	local type = mw.text.trim( args[1] )

	local argList = {
		'type', 'upcoming', 'name', 'ingredients',
		1, 2, 3, 4, 5, 6, 7, 8, 9,
		'A1', 'B1', 'C1', 'A2', 'B2', 'C2', 'A3', 'B3', 'C3',
		'Выход', 'описание'
	}
	
	local data = f:callParserFunction( '#dpl:', {
		category = type .. ' recipe',
		include = '{Крафт}:' .. 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