Verse Library verse

01 Device

Binds a button event to unlock a door device and prints debug messages for tracking interactions.

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

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Native }

# Define our creative_device class. This is the script that runs on the island.
my_lock_script := class(creative_device):

    # Drag your Lock Device from the World Outliner into this property slot
    # in the Details panel after compiling.
    @editable
    LockedDoor : lock_device = lock_device{}

    # Drag your Button Device from the World Outliner into this property slot
    # in the Details panel after compiling.
    @editable
    ControlButton : button_device = button_device{}

    # This function runs when the game starts.
    OnBegin<override>()<suspends> : void =
        # Make sure the door starts locked.
        LockedDoor.Lock()

        # Bind the button's InteractedWithEvent to our handler function.
        # When the button is pressed, RunUnlockLogic() will fire.
        ControlButton.InteractedWithEvent.Subscribe(RunUnlockLogic)

    # This function runs when the button is pressed.
    # button_device events pass the agent who triggered them.
    RunUnlockLogic(Agent : agent) : void =
        # Send a signal to the Lock Device to unlock.

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