Creating your own recipes is as simple as creating a JSON file (schema provided below) and placing it in the FactoryGame/Configs/Recipes
directory and launching the game.
You can also overwrite any recipe in a very similar manner.
If it doesn't exist, and you want to use it, create it!
This mod's recipe format supports basically everything a recipe Blueprint created in Unreal Engine does because it turns the JSON into such a blueprint at runtime.
Below is an example recipe and a screenshot of it working in game.
{
"Name": "BioFuel",
"Ingredients": [
{
"Item": "Coal",
"Amount": 1
}
],
"Products": [
{
"Item": "Biofuel",
"Amount": 10
}
],
"ProducedIn":["ConstructorMk1"],
"UnlockedBy":["Schematic_1-1"]
}
The format of recipe json files follows a JSON Schema, a helpful template that both explains the structure of the file and allows your favorite editors to automatically check your syntax for you. The schema itself is human-readable, so you can also read it to learn the file format.
You can use Visual Studio Code, any JetBrains editor, or more, to get automatic suggestions and see the documentation as you write. Those links go to documentation on how to set it up.
You can view the schema below (may be out of date) or on GitHub here (guaranteed to be up to date).
In addition to creating new recipes, you can also use ContentLib Recipes to modify existing recipes, both base-game recipes and those added by other mods.
The syntax for the recipe is the exact same, but you must put an additional line at the start of the file to specify what recipe to overwrite - the recipe's blueprint path.
You can find this blueprint path from a reference list, via a tool like UModel, or by looking a mod's source code (either online or ingame with ContentInspector).
Below is an example modification of the base game's Biofuel recipe.
//Game/FactoryGame/Recipes/Constructor/Recipe_Biofuel.Recipe_Biofuel_C
{
"Name": "BioFuel Override",
"Ingredients": [
{
"Item": "Coal",
"Amount": 1
}
],
"Products": [
{
"Item": "Biofuel",
"Amount": 10
}
]
}
This Recipe JSON is what most of your recipes will probably look like:
{
"$schema": "https://github.com/Nogg-aholic/ContentLib_Recipes/blob/master/FContentLib_Recipes.json",
"Ingredients": [
{
"Item": "Coal",
"Amount": 1
}
],
"Products": [
{
"Item": "Coal",
"Amount": 1
}
],
"ManufacturingDuration": 1,
"ProducedIn": [
"Build_ConstructorMk1"
],
"UnlockedBy": [
"Schematic_1-1"
],
}
You can check the JSON schema above to find out what fields are optional and which are required. There are a lot more fields on offer, such as craft time.
For example, you could leave out the UnlockedBy
field, but the recipe would not be accessible without some other code to register it. An example of a minimal recipe is presented below.
Items are resolved by comparing the Name against existing Item ClassNames, the first Match is used.
Watch out for ambiguity with Class Names!
To Find a Name you can UModel or browse the SML Project, alternatively here are some Vanilla Names
Classes additionally have a '_C' Tag when generated by a Blueprint, this as well as the Naming Convention related "Build" or "Desc" for Items is optional.
The Reason is simple:
Therefore, this mod uses a Blueprint Path here to reliably load the Recipe to be Patched.
You can use ContentLib Recipes to define the recipes for your own mods.
This makes it easy for end users to configure recipes to their own balance preferences, and can help you quickly create recipes if you want to automatically generate them from another source.
You can follow the examples below to load recipes from your mod's own directories, or create and register recipes from strings alone, or whatever you'd like!
Make sure that you list ContentLib_Recipes
as a required dependency of your own mod, and follow the directions here to be sure that any json files you include in your mod files get packed into your final mod.