using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main script block alert_system := class(creative_device): # We store references to our devices here. # This is like giving them nicknames. @editable MasterSwitch : switch_device = switch_device{} @editable TestSwitch : switch_device = switch_device{} @editable AlertLabel : text_block_device = text_block_device{} # This function runs when the script starts. OnBegin() : void = # Subscribe to the Test Switch events. # When a player turns it on, call OnTestSwitchTurnedOn. # When a player turns it off, call OnTestSwitchTurnedOff. TestSwitch.TurnedOnEvent.Subscribe(OnTestSwitchTurnedOn) TestSwitch.TurnedOffEvent.Subscribe(OnTestSwitchTurnedOff) # Start with the Alert OFF. MasterSwitch.TurnOff() UpdateLabelText(false) # This function updates the text on the screen. # It checks the Master Switch state via a bool we pass in. UpdateLabelText(IsOn : logic) : void = if (IsOn?): # If IsOn is true, the switch is ON. AlertLabel.SetText(StringToMessage("ALERT: ON")) else: # If IsOn is false, the switch is OFF. AlertLabel.SetText(StringToMessage("ALERT: OFF")) # This event happens when the Test Switch is turned On. # It forces the Master Switch to turn On too. OnTestSwitchTurnedOn(Agent : agent) : void = # Turn the master switch on to match. MasterSwitch.TurnOn() # Update the text label. UpdateLabelText(true) # This event happens when the Test Switch is turned Off. # It forces the Master Switch to turn Off too. OnTestSwitchTurnedOff(Agent : agent) : void = # Turn the master switch off to match. MasterSwitch.TurnOff() # Update the text label. UpdateLabelText(false)