using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # This is the "Brain" of our door. # It inherits from creative_device, meaning it can be placed in the world like any other device. secret_door := class(creative_device): # Variables (State): Things that change during the game # 'IsOpen' is a boolean (true/false). Think of it like a light switch. var IsOpen : logic = false # 'DoorPropMover' is a reference to the Prop Mover device. # We'll assign this in the editor. @editable DoorPropMover : prop_mover_device = prop_mover_device{} # 'ButtonTrigger' is the button that activates us. @editable ButtonTrigger : button_device = button_device{} # This function runs when the game starts. # It's like the "Loadout" phase before the match begins. OnBegin() : void = # Connect the button's press event to our custom function ButtonTrigger.InteractedWithEvent.Subscribe(HandleButtonPress) # This is our custom logic. # 'HandleButtonPress' is a function (a set of instructions). # button_device's InteractedWithEvent passes the interacting agent as an argument. HandleButtonPress(Agent : agent) : void = # Check if the door is already open. If it is, do nothing. # This is like checking if a storm is already active before starting the timer. if (IsOpen?): return # Open the door # We call End on our Prop Mover device to move it to its "open" position. DoorPropMover.End() # Update our state set IsOpen = true # Optional: Close the door after 5 seconds # In a real Verse script, you'd use a timer_device here, # but for simplicity, let's just leave it open for now. # In the next tutorial, we'll add the timer back in Verse.