# This script makes a smart door lock # It waits for the player to have a key item using { /Fortnite.com/Devices } using { /Fortnite.com/Game } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # A Verse device that wires a conditional_button_device # to a door_guard_device (the closest real "lock" device in UEFN). # note: UEFN exposes door_guard_device for locking/unlocking doors; # there is no standalone LockDevice class in the public Verse API. MySmartLock := class(creative_device): # Drag-and-drop these in the UEFN outliner after placing the device. @editable MyDoorGuard : door_guard_device = door_guard_device{} @editable MyButton : conditional_button_device = conditional_button_device{} @editable MyItemGranter : item_spawner_device = item_spawner_device{} # OnBegin runs automatically when the game session starts. OnBegin() : void = # Disable the button so players cannot press it yet. MyButton.Disable() # Subscribe to the button's activated event. # When the conditional button decides all conditions are met # and the player presses it, fire OnButtonActivated. MyButton.ActivatedEvent.Subscribe(OnButtonActivated) # Subscribe to the item spawner's pickup event so we know # when the player collects the key item (the torch). # note: item_spawner_device.PickedUpEvent is the real event # for detecting when a spawned item is collected. MyItemGranter.PickedUpEvent.Subscribe(OnKeyItemPickedUp) # Runs when the player picks up the key item from the spawner. OnKeyItemPickedUp(Agent : agent) : void = # The player now has the key item, so enable the button. MyButton.Enable() # Runs when the player successfully activates the conditional button. OnButtonActivated(Agent : agent) : void = # Unlock the door by disabling the door guard. # note: door_guard_device.Disable() removes the guard, # allowing players to pass through the linked door. MyDoorGuard.Disable()