Verse Library verse

01 Device

Broadcasts button activation events across devices using channels, eliminating physical cable wiring.

verse-library/using-channel-devices-in-fortnite-creative/01-device.verse

using { /Fortnite.com/Devices }
using { /Unreal.com/Engine }

# This is our main script. It's the brain of the button.
ChaosController := class(creative_device):
    # We need a reference to the Button so we can listen for clicks.
    ChaosButton: creative_device = creative_device{}

    # We need a reference to the Channel Device to broadcast on.
    RadioStation: channel_device = channel_device{}

    # This function runs when the game starts. Good for setup.
    OnBegin<override>()<suspends>: void =
        # Let's listen for when the button is pressed.
        # We bind to the Button's "Activated" event.
        ChaosButton.ActivatedEvent += OnButtonPressed

    # This function runs whenever the button is pressed.
    OnButtonPressed<override>(player: player): void =
        # TRANSMIT: This is the magic line.
        # We are shouting on "Channel 1".
        # The player who pressed it is also sent along (so devices can know WHO clicked).
        RadioStation.TransmitEvent(1, player)

# This is a helper to make sure the script knows which devices are which.
# In UEFN, you usually drag-and-drop devices into these slots in the editor.

Comments

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