Module:Inventory Crafting

local p = {}

local i18n = { colored = 'Colored', coloredDyes = { 'Orange Dye', 'Magenta Dye', 'Light Blue Dye', 'Dandelion Yellow', 'Lime Dye', 'Pink Dye', 'Gray Dye', 'Light Gray Dye', 'Cyan Dye', 'Purple Dye', 'Lapis Lazuli', 'Cocoa Beans', 'Cactus Green', 'Rose Red', 'Ink Sac', },	categoryIngredientUsage = 'Category:Recipe using $1', categoryRecipeType = 'Category:$1 recipe', categoryUpcoming = 'Category:Upcoming', itemBlockOfQuartz = 'Block of Quartz', itemBoneMeal = 'Bone Meal', itemBrownMushroom = 'Brown Mushroom', itemCharcoal = 'Charcoal', itemCoal = 'Coal', itemColoredDye = 'Colored Dye', itemDye = 'Dye', itemMushroom = 'Mushroom', itemQuartzBlock = 'Quartz Block', itemRedMushroom = 'Red Mushroom', moduleArgs = Module:ProcessArgs, moduleRecipe = Module:Recipe table, moduleSlot = Module:Inventory slot, type = 'Crafting', variantPages = { 'Andesite', 'Banner', 'Diorite', 'Firework Star', 'Granite', 'Pressure Plate', 'Sand', 'Sandstone', 'Shield', 'Slab', 'Stained Glass Pane', 'Stained Glass', 'Stairs', 'Stone Bricks', 'Wood Planks', 'Wood', 'Wool', }, } p.i18n = i18n

local slot = require( i18n.moduleSlot ) local recipeTable = require( i18n.moduleRecipe ).table local cArgVals = { 'A1', 'B1', 'A2', 'B2' } p.cArgVals = cArgVals

function p.table( f ) local args = f	if f == mw.getCurrentFrame then args = require( i18n.moduleArgs ).merge( true ) else f = mw.getCurrentFrame end -- Input fill if args.Input then args.A1 = args.Input args.B1 = args.Input args.A2 = args.Input args.B2 = args.Input end -- Row fillings if args.R1 then args.A1 = args.R1		args.B1 = args.R1       end if args.R2 then args.A2 = args.R2		args.B2 = args.R2       end -- Automatic shapeless positioning if args[1] then args.Shapeless = 1 if args[2] then -- ◼◼			-- ◻◻	               args.A1 = args[1] args.B1 = args[2] if args[3] then -- ◼◼				-- ◻◼			       args.B2 = args[3] if args[4] then -- ◼◼				       -- ◼◼		        	        args.A1 = args[1] args.B1 = args[2] args.A2 = args[3] args.B2 = args[4] end end else -- ◼◻			-- ◻◻			args.A1 = args[1] args.Shapeless = 1 end for i = 1, 4 do			args[i] = nil end end

-- Create recipe table, and list of ingredients local out, ingredientSets = recipeTable( args, {		uiFunc = 'inventoryTable',		type = i18n.type,		ingredientArgs = cArgVals,		outputArgs = { 'Output' },	} ) local title = mw.title.getCurrentTitle if args.nocat == '1' or title.namespace ~= 0 or title.isSubpage then return out end local categories = {} local cI = 1 if args.upcoming then categories[cI] =  .. i18n.categoryUpcoming ..  cI = cI + 1 end if args.type then categories[cI] =  .. i18n.categoryRecipeType:gsub( '%$1', args.type ) ..  cI = cI + 1 end if args.ignoreusage ~= '1' then -- Create ingredient categories for DPL local usedNames = {} for _, ingredientSet in pairs( ingredientSets ) do			for _, ingredient in pairs( ingredientSet ) do				local name = ingredient.name if not ingredient.mod and not usedNames[name] and name ~= title.text then -- List each dye individually as they have their own pages if name == slot.i18n.prefixes.any .. ' ' .. i18n.itemDye or name == slot.i18n.prefixes.matching .. ' ' .. i18n.itemDye or name == slot.i18n.prefixes.any .. ' ' .. i18n.itemColoredDye or name == slot.i18n.prefixes.matching .. ' ' .. i18n.itemColoredDye then if not name:find( i18n.colored ) then categories[cI] =  .. i18n.categoryIngredientUsage:gsub( '%$1', i18n.itemBoneMeal ) ..  cI = cI + 1 usedNames[i18n.itemBoneMeal] = true end for _, dye in ipairs( i18n.coloredDyes ) do categories[cI] =  .. i18n.categoryIngredientUsage:gsub( '%$1', dye ) ..  cI = cI + 1 usedNames[dye] = true end else -- Merge item variants which use a single page if name == slot.i18n.prefixes.any .. ' ' .. i18n.itemMushroom or name == slot.i18n.prefixes.matching .. ' ' .. i18n.itemMushroom or							name == i18n.itemRedMushroom or							name == i18n.itemBrownMushroom then name = i18n.itemMushroom elseif name == i18n.itemCharcoal then name = i18n.itemCoal elseif name:find( ' ' .. i18n.itemQuartzBlock .. '$' ) then name = i18n.itemBlockOfQuartz else for _, variant in pairs( i18n.variantPages ) do if name:find( ' ' .. variant .. '$' ) then name = variant break end end -- Remove prefixes for _, prefix in pairs( slot.i18n.prefixes ) do if name:find( '^' .. prefix .. ' ' ) then name = name:gsub( '^' .. prefix .. ' ', '' ) break end end end if not usedNames[name] then categories[cI] =  .. i18n.categoryIngredientUsage:gsub( '%$1', name ) ..  cI = cI + 1 usedNames[name] = true end end end end end end return out, table.concat( categories, '' ) end

return p