Module:RecipeUsage

local p = {} local cargo = mw.ext.cargo

p.argList = { 'productCount', 'name', 'ingredient1', 'quantity1', 'ingredient2', 'quantity2', 'ingredient3', 'quantity3', 'ingredient4', 'quantity4', 'ingredient5', 'quantity5', 'ingredient6', 'quantity6', 'ingredient7', 'quantity7', 'ingredient8', 'quantity8', 'ingredient9', 'quantity9', 'ingredient10', 'quantity10' }

--Creates recipe table for given recipes -- function createTable(recipes) local table = "" for i=1,#recipes do   if i == #recipes then recipes[i].foot = 1 end recipes[i].structure = 'hidden' table = table .. mw.getCurrentFrame:expandTemplate{title='CraftingTable', args=recipes[i]} end return table end

p.table = function(frame) local ingredient = mw.title.getCurrentTitle.text local fields = table.concat(p.argList, ',') local args = { where = 'ingredient1="' .. ingredient .. '" OR ingredient2="' .. ingredient .. '" OR ingredient3="' .. ingredient .. '" OR ingredient4="' .. ingredient .. '" OR ingredient5="' .. ingredient .. '" OR ingredient6="' .. ingredient .. '" OR ingredient7="' .. ingredient .. '" OR ingredient8="' .. ingredient .. '" OR ingredient9="' .. ingredient .. '" OR ingredient10="' .. ingredient .. '"', orderBy = 'name ASC' }

local recipes = cargo.query('crafting_recipes', fields, args)

return createTable(recipes) end

return p