Verse Library verse

02 Device

Links a button device to a prop manipulator to toggle activation states on player interaction.

verse-library/set-this-property-to-your-button-device/02-device.verse

# This is our main script. It controls the game logic.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

my_button_script := class(creative_device):

    @editable
    MyButton: button_device = button_device{}

    @editable
    MyPropManipulator: prop_manipulator_device = prop_manipulator_device{}

    # A 'var' variable can be changed after it is created.
    # 'false' means the prop is not yet activated.
    var IsActivated: logic = false

    OnBegin<override>()<suspends>: void =
        # Loop forever so the button keeps working after the first press.
        loop:
            # Wait here until the player presses the button.
            MyButton.InteractedWithEvent.Await()

            # Check the current state and flip it.
            if (IsActivated?):
                # It was activated, so deactivate it.
                MyPropManipulator.Deactivate(player{})
                set IsActivated = false
                Print("Deactivated!")
            else:

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