-
Notifications
You must be signed in to change notification settings - Fork 2
Recipe
The recipe object holds information about what object a recipe will craft, what materials are required, and how it will be displayed in the menu. While there are a large number of options here, a simple recipe may simply consist of an id, description and list of materials.
Recipes are highly configurable. See the RecipeData page for a full list of options.
Recipe:new(recipeData: RecipeData): Recipe
Constructs a new Recipe that can be added to an existing MenuActivator.
CraftingFramework.Recipe:new{
id = "recipe_toy_car_01",
craftableId = "misc_toy_car",
description = "A toy car made of a plastic body and four wheels,
materials = {
{ material = "wood", count = 1 },
{ material = "misc_wheel_01", count = 4 },
},
category = "Toys",
},
Recipe.getRecipe(recipeId: string): Recipe
Gets a Recipe object from a recipe id.
local recipeId = "misc_crafted_item_01"
local recipe = CraftingFramework.Recipe.getRecipe(recipeId)
Add two recipes. One for a toy car that would get added to the player's inventory. Requires one "misc_toy_body" and 4 "misc_wheel" items to craft. A second for a chair that is directly placed in-world when crafted, requiring 6 wood to craft. The knowledgeRequirement function ensures the recipe only appears in the crafting menu if the tes3.player.data.knowsChairRecipe
value has been set.
local CraftingFramework = include("CraftingFramework")
if not CraftingFramework then return end
local recipes = {
{
id = "recipe_toy_car_01",
craftableId = "misc_toy_car",
description = "A toy car made of a plastic body and four wheels,
materials = {
{ material = "wood", count = 1 },
{ material = "misc_wheel_01", count = 4 },
},
category = "Toys",
},
{
id = "recipe_portable_chair_01",
craftableId = "portable_chair_misc",
placedObject = "portable_chair_activator",
materials = {
{ material = "wood", count = 6 }
}
category = "Furniture",
knowledgeRequirement = function(_)
return tes3.player.data.knowsChairRecipe == true
end,
}
}
CraftingFramework.MenuActivator:new{
id = "activator_id",
type = "activate",
recipes = recipes
}
Adding a recipe to an existing crafting menu from another mod:
local recipes = {
--add standard crafting framework recipe configs here
}
local function registerRecipes(e)
---@type CraftingFramework.MenuActivator
if e.menuActivator then
for _, recipe in ipairs(recipes) do
e.menuActivator(recipe)
end
end
end
event.register("[MENU_ACTIVATOR_ID]:Registered", registerRecipes)