Module:RecipeUsage

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

p.argList = { 'product_count', 'product_name', 'base_energy', 'base_time', 'ingredient1_name', 'ingredient1_count', 'ingredient2_name', 'ingredient2_count', 'ingredient3_name', 'ingredient3_count', 'ingredient4_name', 'ingredient4_count', 'type' }

--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_name="' .. ingredient .. '" OR ingredient2_name="' .. ingredient .. '" OR ingredient3_name="' .. ingredient .. '" OR ingredient4_name="' .. ingredient .. '"', orderBy = 'product_name ASC' }

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

return createTable(recipes) end

return p