# Recipes

Crafting recipes define what items can be crafted, what ingredients are required, how long crafting takes, and what happens when crafting succeeds.

## Creating a Recipe Entry

Open the Spark Editor, go to **Crafting > Recipes** and click **Create New**.

Each recipe entry defines:

| Field               | Description                                                                                                                                                                  |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Display Name        | Name shown in the crafting UI (e.g., "Iron Sword", "Health Potion").                                                                                                         |
| Description         | Text describing the recipe or its result.                                                                                                                                    |
| Icon                | Sprite for the recipe in the crafting UI.                                                                                                                                    |
| Recipe Category     | The category this recipe belongs to (see [Categories](/documentation/user-guide/plugins/crafting/categories.md)). Used to organize recipes in the crafting UI.               |
| Crafted Item        | The item entry that is produced when this recipe is crafted.                                                                                                                 |
| Craft Duration      | Time in seconds required to craft one instance (default: 1).                                                                                                                 |
| Auto Learn          | If enabled, the recipe is automatically unlocked for the player when they are first initialized. If disabled, the recipe must be unlocked through triggers or quest rewards. |
| Required Components | List of ingredients needed to craft this recipe. See below.                                                                                                                  |
| On Craft Triggers   | List of trigger entries that execute when the recipe is successfully crafted.                                                                                                |

## Required Components

Each required component specifies an ingredient:

| Field  | Description                                    |
| ------ | ---------------------------------------------- |
| Item   | The item entry required as an ingredient.      |
| Amount | How many of this item are needed (default: 1). |

You can add as many components as needed. All components must be present in the player's inventory for the recipe to be craftable. When crafting begins, the required items are consumed from the inventory and the crafted item is added.

## Recipe Unlocking

Recipes can be locked or unlocked. Only unlocked recipes appear in the crafting UI.

**Auto Learn** recipes are unlocked by default when the player is first initialized. All other recipes start locked and must be unlocked through one of these methods:

| Method                 | Description                                                                                                                          |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| Learn Recipe trigger   | A trigger that unlocks a specific recipe for the player. Configure the recipe entry and an optional delay.                           |
| Unlearn Recipe trigger | A trigger that locks a previously unlocked recipe. Configure the recipe entry and an optional delay.                                 |
| Quest reward           | When both Crafting and Quests plugins are installed, the "Unlock Recipe" reward type grants a recipe when a quest reward is claimed. |

Unlocked recipes are tracked in save data and persist across sessions.

## On Craft Triggers

The **On Craft Triggers** list lets you fire any triggers when a recipe is successfully crafted. This is useful for granting experience, advancing quests, playing effects, or any other trigger-based behavior.

## Crafting-Related Requirements

| Requirement         | Description                                                                                      |
| ------------------- | ------------------------------------------------------------------------------------------------ |
| Has Crafting Recipe | Checks if the player has unlocked a specific crafting recipe. Configure the target recipe entry. |

## Quest Integration

When both the Crafting and Quests plugins are installed, additional quest features become available:

**Quest Objectives:**

| Objective     | Description                                                                                                 |
| ------------- | ----------------------------------------------------------------------------------------------------------- |
| Craft Recipe  | Tracks how many times the player crafts a specific recipe (or any recipe if "Allow Any Recipe" is enabled). |
| Unlock Recipe | Completes when the player unlocks a specific recipe.                                                        |

**Quest Rewards:**

| Reward        | Description                                                          |
| ------------- | -------------------------------------------------------------------- |
| Unlock Recipe | Unlocks a specific crafting recipe when the quest reward is claimed. |

## Crafting UI

The Crafting plugin includes a full crafting UI that can be added to your game. The crafting interface is organized into several sections:

**Category Selection** — A sidebar showing all recipe categories plus an "All" category. Each category button shows the category name, icon, and recipe count. Clicking a category filters the recipe list.

**Recipe List** — Shows all recipes in the selected category, organized under category headers. Each recipe slot displays the crafted item's icon, rarity, and how many the player can craft with their current inventory. Recipes the player can craft are highlighted in green; recipes with insufficient materials are highlighted in red.

**Recipe Details** — When a recipe is selected, shows the crafted item icon and rarity alongside a list of required ingredients. Each ingredient displays its icon, name, and an "owned / required" count — green if the player has enough, red if not.

**Craft Controls** — An amount selector with input field, slider, increase/decrease buttons, and a craft button. The maximum craftable amount is calculated from the player's current inventory.

**Crafting Progress** — When crafting is in progress, shows a progress bar with remaining time and a cancel button. Recipes are crafted one at a time from a queue.

The crafting UI automatically updates when the player's inventory changes (gaining or losing ingredients) and when recipes are unlocked or locked.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sparkframework.dev/documentation/user-guide/plugins/crafting/recipes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
