Verse Library verse

01 Device

Manages dynamic mission music by switching tracks when players interact with objects.

verse-library/build-patchwork-x-yacht-heist-in-fortnite-creative/01-device.verse

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

# This is our main device. It controls the music.
JewelHeistDevice := class(creative_device):

    # This is the music track for sneaking.
    @editable
    SneakTrack : audio_player_device = audio_player_device{}

    # This is the music track for escaping.
    @editable
    EscapeTrack : audio_player_device = audio_player_device{}

    # This function runs when the game starts.
    OnBegin<override>()<suspends>:void=
        # Start the sneaking music.
        SneakTrack.Play()

    # This function runs when a player touches the jewel.
    OnPlayerTouchedJewel(Player: agent):void=
        # Stop the sneaking music.
        SneakTrack.Stop()
        # Start the escape music!
        EscapeTrack.Play()
        
        # Print a message to the screen.
        Print("Heist started! Run!")

Comments

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