Verse Library verse

01 Fragment

Trades specific items for rewards when players press a craft button, perfect for crafting stations or quest hubs.

verse-library/using-egg-items-in-fortnite-creative/01-fragment.verse

# Import the necessary Verse libraries for items and players
using /Fortnite.com/Devices
using /Fortnite.com/Items

# Define our main device class
# Think of this as the "Blueprint" for our Crafting Station
class EggCraftingDevice(Device):
    # This is a "Variable". It's a container that holds the button we want to watch.
    # In game terms, it's like pointing a laser at the button you want to program.
    CraftButton: ButtonDevice = "CraftButton_1"

    # This is a "Function". It's a block of code that runs when something happens.
    # Specifically, this runs when the CraftButton is pressed.
    OnCraftButtonPressed := func(player: Player):
        # Check if the player has the required crafting material.
        # "Has_Item" is a function that returns true or false.
        # It's like checking if you have a key before opening a door.
        if (player.Has_Item("White_Dino_Egg_1")):
            
            # If the check passes, remove the Dino Egg (consume the material).
            # "Remove_Item" takes the item away from the player.
            player.Remove_Item("White_Dino_Egg_1", 1)
            
            # Then, give the player the reward: a Heal Egg.
            # "Grant_Item" adds the item to their inventory.
            player.Grant_Item("Heal_Egg_1", 1)
            
            # Optional: Send a message to the player so they know it worked.
            # "Show_Message" is like a text popup on their screen.
            player.Show_Message("Crafted a Heal Egg!")

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

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