Verse Library verse

02 Device

Defines a Creative Device class that toggles stage audio playback using an interactive button and state flag.

verse-library/verse-sound-jukebox-capstone/02-device.verse

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# CAPSTONE: an interactive jukebox that toggles the stage music on a button.
#
# This pulls the whole series together. A Button Device is the jukebox face;
# an Audio Player Device is the speaker stack on the stage. Press the button
# and the music starts; press it again and it stops. The button's
# InteractedWithEvent gives us the press; an @editable label and a playing
# flag give us a real on/off jukebox a designer can drop into any club.
jukebox_device := class(creative_device):

    # The jukebox face the player walks up to and holds-to-use.
    @editable
    JukeboxButton : button_device = button_device{}

    # The speaker stack that actually plays the track.
    @editable
    StageSpeakers : audio_player_device = audio_player_device{}

    # The hint shown on the button when a player looks at it.
    @editable
    StartLabel : string = "Play the music"

    @editable
    StopLabel : string = "Stop the music"

    # Tracks whether the music is currently playing, so each press toggles it.
    var IsPlaying : logic = false

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