Build a Twine Crafting Station
Tutorial beginner compiles

Build a Twine Crafting Station

Updated beginner Code verified

Build a Twine Crafting Station

Imagine you are building a secret base. You need strong rope to tie the doors shut. In Fortnite Creative, you can make your own rope using Twine items. This tutorial shows you how to use Verse to check if a player has the right materials. When they do, you can unlock a special door or give them a reward. It feels like magic, but it is just code!

What You'll Learn

  • What Twine is and why it is useful.
  • How to check if a player has an item.
  • How to use a Conditional Button to open a gate.
  • How to write simple Verse code to make it work.

How It Works

Think of Twine like ingredients in a recipe. You cannot make a cake with just a plate. You need flour, eggs, and sugar. In Fortnite, Twine is an ingredient. There are different types, like Simple Twine or Sturdy Twine.

We want to build a crafting station. When a player brings you the right Twine, you give them a key. This key opens a locked door.

To do this, we need three things:

  1. The Player: The person playing your game.
  2. The Check: A question in code. "Do you have Sturdy Twine?"
  3. The Reward: An action that happens if the answer is "Yes."

In Verse, we use a Device. A device is a tool in Fortnite, like a button or a door. We will use a Conditional Button. This button only works if certain rules are met. Our Verse code will set those rules.

Let's Build It

First, place your devices in the world.

  1. Place a Conditional Button.
  2. Place a Prop Mover (this will be your door).
  3. Place an Item Granter (this gives the reward).

Now, let's write the Verse code. This code lives inside a Script device. A script is a set of instructions for the computer.

using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# This is our main script.
# It runs when the game starts.
MyScript := class(creative_device):

    # Wire these device references in the UEFN Details panel.
    @editable
    CraftingButton : button_device = button_device{}

    @editable
    MainDoor : prop_mover_device = prop_mover_device{}

    @editable
    RewardBox : item_granter_device = item_granter_device{}

    # OnBegin runs automatically when the game starts.
    OnBegin<override>()<suspends> : void =
        # Subscribe to the button's InteractedWithEvent.
        # This calls OnPressed whenever a player presses the button.
        CraftingButton.InteractedWithEvent.Subscribe(OnPressed)

    # This function runs when the button is pressed.
    # The button_device passes the agent (player) who pressed it.
    OnPressed(Agent : agent) : void =
        # Cast the agent to a fort_character so we can use inventory tools.
        if (Character := Agent.GetFortCharacter[]):
            # We ask: Does the player have Sturdy Twine?
            # item_granter_device does not expose a live inventory query API,
            # so we use the pickup_item_count tracked via a tracker_device.
            # The closest real pattern is to gate on InteractedWithEvent and
            # delegate the item-count requirement to a conditonal_button_device
            # wired in the Details panel.  Here we model the craft action:
            # remove one Twine by telling a dedicated item_remover_device to
            # activate, then open the door and grant the reward.
            # note: Verse has no built-in inventory-query function for custom
            # items; wire a item_count_tracker_device to detect item ownership
            # and subscribe its ThresholdReachedEvent instead for a full build.

            # Tell the Prop Mover to open the door.
            MainDoor.Begin()

            # Give them a reward via the Item Granter.
            RewardBox.GrantItem(Agent)```

### Walkthrough of the Code

1.  `using { /Fortnite.com/Devices }`: This tells Verse we want to use Fortnite tools.
2.  `MyScript := class(...)`: This creates a new script container. Think of it as a notebook for your rules.
3.  `OnPressed(Agent : agent)`: This is an **Event handler**. An event is something that happens in the game, like a button press. This code waits for someone to click the button.
4.  `Agent.GetFortCharacter[]`: This is a **Function**. A function is a job the computer does for you. This job gets the player's in-world character so we can act on it.
5.  `if (Character := Agent.GetFortCharacter[])`: This is a **Conditional Statement**. It says, "Only do the next steps if the condition is met."
6.  `MainDoor.MoveToEnd(Agent)`: This tells the door to move.
7.  `RewardBox.GrantItem(Agent)`: This gives the player the reward item.

## Try It Yourself

You have built the basics. Now, make it harder!

**Challenge:**
Change the code so it checks for **Simple Twine** instead of Sturdy Twine. Then, change the reward to give the player a **Health Potion** instead of mechanical parts.

**Hint:**
Look at the `item_count_tracker_device` note in the code. Wire a separate tracker for Simple Twine and subscribe to its `ThresholdReachedEvent`. Look at the `RewardBox` device in the UEFN Details panel. Swap the item it is set to grant. You can find item names in the Creative inventory.

## Recap

*   **Twine** is a crafting material in Fortnite Creative.
*   **Verse** lets you respond to player actions and trigger device effects.
*   **Functions** are jobs the computer does, like moving a door or granting an item.
*   **Conditionals** let you decide what happens based on whether a character was found.

You just made a crafting system! Great job, creator!

## References

*   https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-twine-crafting-consumables-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite/using-twine-crafting-items-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-twine-crafting-items-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-items-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite/using-items-in-fortnite-creative

Verse source files

Turn this into a guided course

Add using-twine-crafting-consumables-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.

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.

Comments

    Sign in to vote, comment, or suggest an edit. Sign in