using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Native }
my_lock_script := class(creative_device):
@editable
LockedDoor : lock_device = lock_device{}
@editable
ControlButton : button_device = button_device{}
OnBegin<override>()<suspends> : void =
LockedDoor.Lock()
ControlButton.InteractedWithEvent.Subscribe(RunUnlockLogic)
RunUnlockLogic(Agent : agent) : void =
LockedDoor.Unlock()
Print("Door Unlocked! Loot is yours.")
# Spin up a background task so the button stays responsive
# while we wait to re-lock.
spawn { RelockAfterDelay() }
# <suspends> lets us use Sleep() to pause without freezing the game.
RelockAfterDelay()<suspends> : void =
Sleep(5.0)
LockedDoor.Lock()
Print("Door Locked again. Too slow!")
Verse Library
verse
02 Device
Unlocks a door via button press, then automatically re-locks it after a delay without freezing the game.
verse-library/using-lock-devices-in-fortnite-creative/02-device.verse