Verse Library verse

01 Device

Links physical switches to dynamic on-screen text alerts for player awareness.

verse-library/master-alert-switch/01-device.verse

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

# This is our main script block
alert_system := class(creative_device):
    # We store references to our devices here.
    # This is like giving them nicknames.
    @editable
    MasterSwitch : switch_device = switch_device{}
    @editable
    TestSwitch : switch_device = switch_device{}
    @editable
    AlertLabel : text_block_device = text_block_device{}

    # This function runs when the script starts.
    OnBegin<override>()<suspends> : void =
        # Subscribe to the Test Switch events.
        # When a player turns it on, call OnTestSwitchTurnedOn.
        # When a player turns it off, call OnTestSwitchTurnedOff.
        TestSwitch.TurnedOnEvent.Subscribe(OnTestSwitchTurnedOn)
        TestSwitch.TurnedOffEvent.Subscribe(OnTestSwitchTurnedOff)

        # Start with the Alert OFF.
        MasterSwitch.TurnOff()
        UpdateLabelText(false)

    # This function updates the text on the screen.
    # It checks the Master Switch state via a bool we pass in.
    UpdateLabelText(IsOn : logic) : void =

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