The Magic Kitchen: Crafting Items in Fortnite
Unverified — this example may not compile as-is.
The Verse code below did not pass our automated compile check, so it isn't marked verified and is hidden from the guide listing. The explanation may still be useful, but treat the code as a draft and adapt it before use.
The Magic Kitchen: Crafting Items in Fortnite
Have you ever played Fortnite and found a weird item like a Stink Sac or a Lemon Lime? You might wonder, "What do I do with this?"
In Creative mode, these items are secret ingredients! You can use them to cook up new tools. This tutorial shows you how to build a crafting station. You will turn simple items into powerful gear. It is like playing with edible LEGOs.
What You'll Learn
- How to find Crafting Items and Food Items.
- What a Conditional Button is and why it is a bouncer.
- How to set up a simple trade system.
- How to give players new items after they trade.
How It Works
Imagine you are at a pizza shop. You need cheese and dough to make a slice. If you only have cheese, the chef says, "Not yet!"
In Fortnite Creative, we use a Conditional Button as the chef. This device checks your bag. It looks for specific items. If you have the right mix, it opens a door. If not, it stays closed.
There are two main types of ingredients:
- Food Items: These are things like Wheat, Herbs, or Roasted Chicken.
- Crafting Items: These are weird things like Animal Bones or Mechanical Parts.
You cannot eat Crafting Items. They are just for trading. You can eat Food Items, but we will use them as ingredients here.
The Scene Graph: Where Things Live
Before we code, let's look at the Scene Graph. Think of this as a family tree for your island.
- Entity: This is any object in your game. A player, a button, or a box.
- Component: This is a trait attached to an entity. The Conditional Button has a "Condition" component.
We will place our Conditional Button in the world. Then, we will tell it what to look for. When the player has the items, the button will "fire." This fires an event. The event will spawn a new item for the player.
Let's Build It
We will build a station where players trade Herb and Wheat for a Meat item.
First, place a Conditional Button in your island. Make sure it is facing a clear spot where the player can stand.
Here is the Verse script. This script tells the button what to check for.
# This is our crafting station script
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Fortnite.com/FortPlayerUtilities }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# We create a new device called "CraftingStation"
crafting_station := class(creative_device):
# This is the button that checks the items
# We link it to the Conditional Button in the editor
@editable
my_button : conditional_button_device = conditional_button_device{}
# This is the item we give to the player when the recipe is complete
# We link it to an Item Granter in the editor
@editable
my_granter : item_granter_device = item_granter_device{}
# This is the item remover for the first ingredient (Herb)
# Set its item type to Herb in the editor, quantity 1
@editable
herb_remover : item_remover_device = item_remover_device{}
# This is the item remover for the second ingredient (Wheat)
# Set its item type to Wheat in the editor, quantity 1
@editable
wheat_remover : item_remover_device = item_remover_device{}
# When the game starts, we get ready
OnBegin<override>()<suspends> : void =
# We connect the button's ItemRemovedEvent to our function.
# The conditional_button_device fires ItemRemovedEvent when
# its built-in item conditions are all satisfied.
# Configure the required items (Herb x1, Wheat x1) directly
# in the Conditional Button's Details panel in the editor.
my_button.ItemRemovedEvent.Subscribe(OnCraft)
# This function runs when the button's conditions are met.
# It receives the agent (player) who pressed the button.
OnCraft(InAgent : agent) : void =
# Remove the ingredient items from the player's inventory.
# Each item_remover_device is pre-configured in the editor
# to remove one copy of its assigned item from the activating player.
herb_remover.Remove(InAgent)
wheat_remover.Remove(InAgent)
# Give the player their crafted item via the Item Granter.
my_granter.GrantItem(InAgent)
# Print a message to the log for debugging.
# note: agent has no direct Print method; cast to fort_character for display,
# or use a hud_message_device for on-screen feedback instead.
Print("Yum! You made Meat!")```
### How to Set This Up in UEFN
1. **Place the Button:** Drag a Conditional Button into your scene.
2. **Place the Granter:** Drag an Item Granter near the button. Set its item to "Meat" (or any food/crafting item).
3. **Place the Removers:** Drag two Item Remover devices into your scene. Set one to remove **Herb** and the other to remove **Wheat**, each with a quantity of 1.
4. **Link in Verse:**
* Click on your `crafting_station` device in the viewport.
* In the Details panel, find the "Verse" section.
* Link `my_button` to the Conditional Button device.
* Link `my_granter` to the Item Granter device.
* Link `herb_remover` to the Herb remover device.
* Link `wheat_remover` to the Wheat remover device.
5. **Configure the Conditional Button:** In the Conditional Button's own Details panel, add Herb and Wheat as required items. This is what makes `SuccessEvent` fire only when the player has both.
6. **Test It:** Play your island. Pick up an Herb and Wheat. Walk up to the button. Press it!
## Try It Yourself
You did it! You made a working crafting station. Now, let's make it harder.
**Challenge:** Change the recipe. Instead of Herb and Wheat, try using **Lemon Lime** and **Milk**.
**Hint:** Look at the Item Remover devices and the Conditional Button settings in the editor. Change the item types there. Also swap `herb_remover` and `wheat_remover` for `lemon_remover` and `milk_remover` in the Verse script, and update the variable names so they match. Make sure you also change the message on the screen so it makes sense!
## Recap
* **Crafting Items** are special resources like Bones or Parts.
* **Food Items** are ingredients like Wheat or Herbs.
* The **Conditional Button** checks your bag for specific items using its built-in item conditions.
* **Item Remover** devices cleanly take ingredients out of the player's inventory.
* When you have the right items, the button fires `SuccessEvent` and your Verse code handles the trade.
You are now a master chef of Fortnite Creative! Keep experimenting with different items.
## References
* https://dev.epicgames.com/documentation/en-us/fortnite/using-food-crafting-items-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-food-crafting-consumables-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-crafting-items-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite/using-crafting-items-in-fortnite-creative
* https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-produce-items-in-fortnite-creative
Verse source files
- 01-device.verse · device
Turn this into a guided course
Add using-food-crafting-items-in-fortnite-creative to your free study plan — we'll suggest related pages and stitch the lot into one compile-checked, self-guided lesson with worked examples and quizzes.
References
Original tutorial generated by Verse Island from the Verse/UEFN knowledge base, with references to the Epic Games sources above. Code is validated against the knowledge base.