recipes
- raw
A collection of all recipes indexed by their name.
- Example:
import json from draftsman.data import recipes print(json.dumps(recipes.raw["iron-plate"], indent=4))
{ "type": "recipe", "ingredients": [ [ "iron-ore", 1 ] ], "result": "iron-plate", "energy_required": 3.2, "category": "smelting", "name": "iron-plate" }
- categories
A
dict
of lists of valid recipes organized by their category. Exists as the format:See also
{ "category_name": [ "recipe_1", "recipe_2", # ... ], # ... }
- Example:
import json from draftsman.data import recipes print(json.dumps(recipes.categories["centrifuging"], indent=4))
[ "uranium-processing", "nuclear-fuel", "nuclear-fuel-reprocessing", "kovarex-enrichment-process" ]
- for_machine
A
dict
of lists of valid recipes for eachAssemblingMachine
. Exists as the format:{ "machine_name" : [ "recipe_1", "recipe_2", # ... ], # ... }
- Example:
import json from draftsman.data import recipes print(json.dumps(recipes.for_machine["oil-refinery"], indent=4))
[ "advanced-oil-processing", "coal-liquefaction", "basic-oil-processing" ]
- get_recipe_ingredients(recipe_name: str, expensive: bool = False) set[str]
Returns a
set
of all item types thatrecipe_name
requires. Discards quantities.First attempts to get the
"ingredients"
key from the recipe. If that fails, we then attempt to get the contents of the"normal"
key from recipe (which is the list of ingredients under non-expensive map settings).Note
Assumes that the items required for ‘normal’ mode are the same as ‘expensive’ mode. This is unlikely true under all circumstances, but how will we issue warnings for invalid item requests if we dont know what mode the world save is in?
- Parameters:
recipe_name – The name of the recipe to get the ingredients of.
expensive – Whether or not to return the expensive recipe if available. If not, defaults to the normal recipe requirements.
- Returns:
A
set
of names of each Factorio item that the recipe requires.- Raises:
KeyError – If
recipe_name
is not a valid recipe.- Example:
print(recipes.get_recipe_ingredients("electronic-circuit")) # {'iron-plate', 'copper-cable'}