Module:Crafting usage

local p = {} function p.dpl( f ) local args = require( 'Module:ProcessArgs' ).merge if args.upcoming or args.ignoreusage then return end local title = f:callParserFunction( '#dplvar:craftingdplingredient' ) if title == '' then title = mw.title.getCurrentTitle.text end local craftingArgs = { args[1] or args.A1 or , args[2] or args.B1 or , args[3] or args.C1 or '', args[4] or args.A2 or , args[5] or args.B2 or , args[6] or args.C2 or '', args[7] or args.A3 or , args[8] or args.B3 or , args[9] or args.C3 or '', Output = args.Output }	local matchType = f:callParserFunction( '#dplvar:craftingdplmatch' ) local pattern if matchType == 'start' then pattern = '[;:%]]%s*' .. title elseif matchType == 'end' then pattern = title .. '%s*[,;%[]' elseif matchType == 'any' then pattern = title else pattern = '[;:%]]%s*' .. title .. '%s*[,;%[]' end local usedRecipes = f:callParserFunction( '#dplvar:craftingdplrecipes' ) local hasIngredient for _, v in ipairs( craftingArgs ) do if ( ';' .. v .. ';' ):find( pattern ) then if usedRecipes:find( args.Output ) then return end if not v:find( ';' ) then hasIngredient = 'static' elseif not hasIngredient then hasIngredient = 'animated' end end end if not hasIngredient then return end local maxFrames = 1 local requiredFrames = {} if hasIngredient == 'animated' then for _, v in ipairs( craftingArgs ) do			if v:find( ';' ) then local frameNum = 0 for frame in mw.text.gsplit( v, '%s*;%s*' ) do					frameNum = frameNum + 1 if frameNum > maxFrames then maxFrames = frameNum end if not requiredFrames[frameNum] and ( ';' .. frame .. ';' ):find( pattern ) then requiredFrames[frameNum] = true end end end end end if maxFrames > 1 then local frames = {} for k, arg in pairs( craftingArgs ) do			if arg:find( ';' ) then local frameNum = 0 for frame in mw.text.gsplit( arg, '%s*;%s*' ) do					frameNum = frameNum + 1 if requiredFrames[frameNum] then if not frames[k] then frames[k] = {} end table.insert( frames[k], frame ) end end frames[k] = table.concat( frames[k], ';' ) else frames[k] = arg end end f:callParserFunction( '#dplvar:set', 'craftingdplrecipes', usedRecipes .. ';' .. frames.Output ) if args[1] then local argNum = 0 for _, arg in ipairs( frames ) do				if arg ~= '' then argNum = argNum + 1 args[argNum] = arg end end args.Output = frames.Output else args.A1 = frames[1]; args.B1 = frames[2]; args.C1 = frames[3] args.A2 = frames[4]; args.B2 = frames[5]; args.C2 = frames[6] args.A3 = frames[7]; args.B3 = frames[8]; args.C3 = frames[9] args.Output = frames.Output end -- If not all frames are used, overwrite custom name and ingredient values if maxFrames > #requiredFrames then args.name = nil args.ingredients = nil end else f:callParserFunction( '#dplvar:set', 'craftingdplrecipes', usedRecipes .. ';' .. args.Output ) end local crafting = require( 'Module:Crafting' ).table args.head = '1' args.foot = nil args.nocat = '1' args.showdescription = f:callParserFunction( '#dplvar:craftingdescription' ) return crafting( args ) end return p