using { /Fortnite.com/Devices } using { /Verse.org/Simulation } # This is our custom device. It holds the button and door. # Think of it as a box containing both parts. MySecretDoor := class(creative_device): # These are the pieces we will connect in the editor. # A 'variable' is a name for a thing that can change. @editable Button : button_device = button_device{} @editable Door : door_device = door_device{} # This function runs when the game starts. # It sets up the "phone line" between button and door. OnBegin() : void = # Subscribe means "listen for this event." # When the button is pressed, run the OpenDoor function. Button.InteractedWithEvent.Subscribe(OpenDoor) # This is the function that actually opens the door. # The agent parameter is required by InteractedWithEvent's delegate signature. OpenDoor(Agent : agent) : void = # This tells the door to open! Door.Open() # Let's add a little delay so the door doesn't snap instantly. # It waits 1 second, then closes. Sleep(1.0) Door.Close()