using { /Fortnite.com/Devices } using { /Verse.org/Simulation } # This is our smart script for the door SmartDoor := class(verse_device): # We connect to the door device here. # This is like plugging in a wire. Door: lock_device = lock_device{} # We connect to the trigger volume here. # This is like setting up a motion sensor. Trigger: volume_device = volume_device{} # This variable remembers if the door is open. # It starts as false (closed). var IsDoorOpen: logic = false # This runs when the game starts. OnBegin(): void = # We tell the trigger: "Watch for players!" # When a player enters, run the function below. Trigger.AgentEntersEvent.Subscribe(OnPlayerEnter) # This function runs when a player enters the trigger. OnPlayerEnter := func(agent: agent): void = # Check if the door is already open. if (IsDoorOpen == false): # Unlock the door for this player. # Think of this as turning the key. Door.Unlock(agent) # Open the door. # Think of this as pushing the door open. Door.Open(agent) # Update our sticky note. # Now the door is open! IsDoorOpen = true