Verse Library verse

01 Device

Uses a trigger volume event to activate a campfire prop, demonstrating basic puzzle logic for new creators.

verse-library/build-a-game/01-device.verse

# This is a comment. It explains the code.
# We are making a script that watches for players.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

# This is our main game manager class.
# It holds the devices we named earlier.
campfire_script := class(creative_device):

    # MyTrigger is our trigger volume device.
    # Connect it in the Details panel in UEFN.
    @editable
    MyTrigger : trigger_device = trigger_device{}

    # SecretCampfire is our campfire device.
    # Connect it in the Details panel in UEFN.
    @editable
    SecretCampfire : campfire_device = campfire_device{}

    # This function runs when the game starts.
    OnBegin<override>()<suspends> : void =
        # We wait for the trigger to activate.
        # This means a player walked into the box.
        MyTrigger.TriggeredEvent.Await()
        # We tell the campfire to light up.
        SecretCampfire.AddWood()

Comments

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