Enable device array

Hi! Is there a way to send events for all devices inside an array?

Example: I want to enable all switch devices in the “Switches” array.

@editable Switches : []switch_device = array{}
@editable EnableTrigger : trigger_device = trigger_device{}

# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
    EnableTrigger.TriggeredEvent.Subscribe(EnableSwitch)


EnableSwitch(Agent:?agent):void=
    (I want to enable all switches here)
OnBegin<override>()<suspends>:void=
    EnableTrigger.TriggeredEvent.Subscribe(EnableSwitch)


EnableSwitch(Agent:?agent):void=
    for(Switch:Switches):
            Switch.Enable()

Thank you! One quick question, how can I turn the switch on? When I try to turn it on I get this message.

? Switches dont need an agent to enable can you show a screenshot of the script?

Here is the full script

Replace with Switch.SetState(false)

1 Like