Verse Library verse

01 Fragment

Defines a handler that enables a trap and prints a message when a player uses a button.

verse-library/verse-functions-and-when-to-use-them-in-a-fortnite-island/01-fragment.verse

# This is a Verse Device. It lives in your island.
# It watches for events and controls other devices.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

device ButtonTrapController : creative_device {

    # We need a way to talk to the trap.
    # We will link this in the editor later.
    @editable
    Trap : trap_device = trap_device{}

    # This is our main function.
    # It runs when the button is pressed.
    # It is <suspends> because it can be used with async events.
    OnButtonPressed(Agent : agent) : void {
        # This line tells the trap to enable and trigger!
        Trap.Enable()
        
        # This line prints a message to the console.
        # It helps you know the code worked.
        Print("Boom! The trap fired!")
    }
}

Comments

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