Verse Library verse

01 Standalone

Connects a button press to activating a moving trap, letting players trigger effects by interacting with devices.

verse-library/activate-1/01-standalone.verse

# We need to talk to Fortnite devices, so we import the device library.
using { /Fortnite.com/Devices }

# This is our main script. It lives in the scene graph.
RevengeTrapScript := class(creative_object):
    # We need references to our devices.
    # Think of these as "handles" to the objects in the world.
    RevengeButton: conditional_button_device = conditional_button_device{
        # Replace this with the actual name of your button in the editor
        name = "RevengeButton" 
    }
    
    SpikeTrap: prop_mover_device = prop_mover_device{
        # Replace this with the actual name of your trap in the editor
        name = "SpikeTrap"
    }

    # This function runs when the game starts.
    OnBegin<override>()<synchronized>: void =>
        # 1. Listen for the button being pressed.
        # When the button is pressed, run the 'ButtonPressed' function.
        RevengeButton.PressedEvent += func(agent: agent):
            # 2. The button was pressed! Now we activate the trap.
            # We pass the 'agent' (the player who pressed it) to the Activate function.
            # This tells the trap: "Hey, this player triggered you. Go!"
            SpikeTrap.Activate(agent)

Comments

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