Verse Library verse

01 Device

Links a switch device to a video player device, triggering video playback when players flip the switch.

verse-library/video-player/01-device.verse

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

# This is our main script.
# It connects to the world and controls our devices.
concert_manager := class(creative_device):

    # We need to find our devices.
    # Drag and drop your devices onto these properties
    # in the UEFN editor to connect them.
    @editable
    MySwitch : switch_device = switch_device{}

    @editable
    MyVideo : video_player_device = video_player_device{}

    # This function runs when the game starts.
    # It sets up the connections.
    OnBegin<override>()<suspends> : void =
        # We tell the switch to listen.
        # When a player turns it on, it calls 'PlayVideo'.
        MySwitch.TurnedOnEvent.Subscribe(OnSwitchActivated)

    # This function runs when the switch is flipped.
    OnSwitchActivated(Agent : agent) : void =
        # This line plays the video!
        # We use a special video ID.
        # note: SetVideoId is not available in the public Verse API;
        # the video URL/ID is configured in the video_player_device

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