# This is a comment. It helps humans read the code. # The computer ignores comments. using { /Fortnite.com/Devices } using { /Fortnite.com/Game } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } # We create a new "Device" type called MyTeamSwitch. # It has two parts: a Switch and a Door. MyTeamSwitch := class(creative_device): # These are the "components" or parts of our device. # You assign real devices to these in the UEFN editor, on the Verse device actor. @editable SwitchDevice : button_device = button_device{} @editable DoorDevice : conditional_button_device = conditional_button_device{} # note: UEFN has no native DoorDevice API; conditional_button_device is the # closest real creative_device you can drop and wire up to a door prop. # This function runs when the game starts. OnBegin() : void = # We set a rule for the switch. # Only Blue Team (team index 1) can interact with it. # note: Verse has no SetActivationTeam method on button_device. # Team filtering is configured in the editor on the Button Device itself, # or checked here by reading the agent's team at runtime (see below). Agent := SwitchDevice.InteractedWithEvent.Await() # We link them together here. # When the button is pressed, activate the conditional button (linked to the door). DoorDevice.Activate(Agent) # Helper: loop forever, only acting when a Blue Team agent presses the button. # Call this instead of the simple OnBegin above for the full team-check version. RunTeamFilter() : void = loop: # Wait for any agent to interact with the switch. Agent := SwitchDevice.InteractedWithEvent.Await() # Check if the agent is on Blue Team (team index 1). if (FortCharacter := Agent.GetFortCharacter[]): TeamCollection := GetPlayspace().GetTeamCollection() if (AgentTeam := TeamCollection.GetTeam[Agent], Teams := TeamCollection.GetAgents[AgentTeam]): # Open the door by activating its linked device! DoorDevice.Activate(Agent)