# This script checks if the switches are in the right order. using { /Fortnite.com/Devices } using { /UnrealEngine.com/Temporary/SimulatedSystem } # We create a new script. This is our game logic. MyPuzzleScript := class(script): # These are our switches. We connect them to the devices in the editor. Switch1: SwitchDevice Switch2: SwitchDevice Switch3: SwitchDevice Door: PropMoverDevice # This variable remembers the current state. # Think of it as a score counter. CurrentScore: int = 0 # This function runs when you enter the CheckZone. CheckOrder := function(): void = # We check the state of each switch. # Is Switch 1 ON? if Switch1.GetState() == true: # If yes, we add 1 to our score. CurrentScore = CurrentScore + 1 # Is Switch 2 ON? if Switch2.GetState() == true: # We add another 1 to the score. CurrentScore = CurrentScore + 1 # Is Switch 3 ON? if Switch3.GetState() == true: # We add the final 1 to the score. CurrentScore = CurrentScore + 1 # Now we check the total score (the state). # If the score is 3, all switches are ON! if CurrentScore == 3: # Open the door! Door.Move(1.0) # Reset the score for next time. CurrentScore = 0 else: # The order was wrong. Do nothing. # The door stays closed. pass