Fish in a Barrel: Your First Verse Script
Fish in a Barrel: Your First Verse Script
Welcome to the shore! Today, we are going to build a fishing spot. You know how in games you need gear to start playing? We will make a barrel that gives players a fishing rod. This is the perfect first step into Verse.
We will learn how to make one object talk to another. You will see how devices work together. By the end, you will have a working fishing zone. Let’s dive in!
What You'll Learn
- How to use Verse to control game items.
- How to give players a Fishing Rod.
- How to link a Barrel to a Fishing Zone.
- How to use Events to trigger actions.
How It Works
Imagine a treasure chest. You open it, and poof! You get gold. In Verse, we do the same thing. We have a Device. A device is like a machine in your island. It has buttons and lights.
Our device is the Fishing Rod Barrel. When a player presses "E" to search it, something happens. Usually, barrels just sit there. But with Verse, we can make it do more!
We want two things to happen:
- The player gets a Creative Fishing Rod. This is the tool they use to fish.
- The player knows where to fish. We will light up a Fishing Zone.
Think of the Barrel as the "Boss." It tells the Rod what to do. It also tells the Zone it is time to open. We use a special word called an Event. An event is like a bell ringing. When the bell rings, the code runs.
We will also use a Function. A function is a set of instructions. It is like a recipe. You tell the computer: "Get rod, give to player, light up zone." Now you can say that whole recipe with one word!
Let's Build It
First, place a Fishing Rod Barrel in your island. Place a Fishing Zone nearby. Make sure the zone is big enough to stand in.
Now, we write the script. This script lives inside the Barrel.
# We are making a script for the Barrel.
# This is called a "Device Script".
# This is our recipe (Function).
# It takes the player who found the barrel.
Give_Fishing_Gear := (player : Player) -> unit:
# This line gives the player a fishing rod.
# It's like handing them a tool.
player.Grant_Item("Creative_Fishing_Rod")
# This line turns on the fishing zone.
# We assume the zone is named "My_Fishing_Zone".
My_Fishing_Zone.Enable()
# Print a message to the chat.
# This helps us know it worked.
Print("Here is your fishing gear!")
# This is the Event.
# It rings when a player searches the barrel.
On_Search := (params : On_Search_Params) -> unit:
# Get the player who searched.
player := params.Player
# Run our recipe!
Give_Fishing_Gear(player)
Walkthrough
Let’s look at the code line by line.
Give_Fishing_Gear := (player : Player) -> unit:
This starts our recipe. We call it Give_Fishing_Gear. It needs one thing: the player. The unit means it doesn’t give back anything. It just does the work.
player.Grant_Item("Creative_Fishing_Rod")
This is the magic line. It finds the player’s inventory. It adds the "Creative Fishing Rod" to it. Now the player can equip it!
My_Fishing_Zone.Enable()
This turns on the zone. It glows green. It tells the game: "You can fish here now!" Make sure your zone is named My_Fishing_Zone in the editor.
On_Search := (params : On_Search_Params) -> unit:
This is the bell. It waits for the player to press "E". When they do, it sends params. These are the details of the search.
player := params.Player
We pull the player out of the details. Now we know who searched the barrel.
Give_Fishing_Gear(player)
We call our recipe. We pass the player to it. The code runs the steps inside the recipe.
Try It Yourself
Great job! You built the base script. Now, let’s make it better.
Challenge: Right now, the zone stays on forever. What if you want the zone to turn off after 10 seconds?
Hint:
Look for a function called Delay. It waits for a time, then does something. You can put it inside your recipe. Try adding a delay before turning off the zone.
Can you make the zone turn off after 5 seconds? Give it a try!
Recap
You just wrote your first Verse script! You learned how to:
- Create a Function (a recipe).
- Trigger it with an Event (a bell).
- Give items to players using
Grant_Item.
You made a barrel that helps players start their fishing adventure. That is real programming! Keep building and have fun.
References
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-fishing-rod-barrel-devices-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/using-fishing-rod-barrel-devices-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/using-fish-items-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-fishing-consumables-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-fish-consumables-in-fortnite-creative
Verse source files
- 01-fragment.verse · fragment
Turn this into a guided course
Add Fish in a Barrel 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.