Verse Library verse

01 Device

Subscribes to a trigger volume event to permanently disable a hiding prop door upon player activation.

verse-library/disable/01-device.verse

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

# This is our main script. Think of it as the brain of the trap.
TrapDoorBrain := class(creative_device):
    # We need to tell the script which devices we are controlling.
    # 'MyDoor' is the name we give to the Hiding Prop in the code.
    # 'PressurePlate' is the name we give to the Trigger Volume.
    @editable
    MyDoor : hiding_prop_device = hiding_prop_device{}
    @editable
    PressurePlate : trigger_device = trigger_device{}

    OnBegin<override>()<suspends>: void =
        # This runs when the game starts.
        # We set up the 'listener' for when someone steps on the plate.
        # 'TriggeredEvent' is an event that fires when an agent (player) activates the trigger.
        PressurePlate.TriggeredEvent.Subscribe(OnTriggered)

    OnTriggered(Agent : ?agent) : void =
        # When someone enters the plate...
        # 1. We disable the door.
        # This makes the door stop responding to interactions.
        # It effectively 'locks' the state of the door.
        MyDoor.Disable()

        # Optional: You could also play a sound or spawn an explosion here!
        Print("Door is now disabled! No more interacting.")

Comments

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