Module:Recipe list
Jump to navigation
Jump to search
This module is used to list all recipes in a particular category.
The type function will match recipes which have the type parameter set to the same value as the input.
Example[edit source]
{{#invoke:recipe list|type|Foodstuff}}
, lists all recipes with type set to Foodstuff.
Name | Ingredients | Crafting recipe | [hide]Description |
---|---|---|---|
Beetroot Soup | Beetroot + Bowl |
||
Bread | Wheat | ||
Cake | Milk Bucket + Sugar + Any Egg + Wheat |
Empty buckets remain in the crafting grid after crafting the cake. | |
Cookie | Wheat + Cocoa Beans |
||
Dried Kelp | Dried Kelp Block | ||
Golden Apple | Gold Ingot + Apple |
||
Golden Carrot | Gold Nugget + Carrot |
||
Honey Bottle | Glass Bottle + Honey Block |
||
Mushroom Stew | Red Mushroom + Brown Mushroom + Bowl |
||
Pumpkin Pie | Pumpkin + Sugar + Any Egg |
||
Rabbit Stew | Cooked Rabbit + Carrot + Baked Potato + Any Mushroom + Bowl |
||
Suspicious Stew | Red Mushroom + Brown Mushroom + Bowl + Any Small Flower |
[view] [edit] [history] [refresh]The above documentation is transcluded from Module:Recipe list/doc.
local p = {}
function p.type( f )
local args = f.args
local crafting = require( [[Module:Crafting]] ).table
local type = mw.text.trim( args[1] )
local showDesciption
local templates = {}
local query = {
'[[Crafting type::'..type..']]',
'?Crafting JSON',
limit = 500
}
local smwdata = mw.smw.ask(query)
if smwdata then
for _,v in ipairs(smwdata) do
if _G.type(v['Crafting JSON']) ~= "table" then
local tArgs = mw.text.jsonDecode(v['Crafting JSON'])
if tArgs.description then
showDescription = true
end
tArgs.nocat = '1'
table.insert( templates, tArgs )
else
mw.log("ERROR: Recipe query returned table.")
mw.logObject(v, "DATA")
end
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