Where can I get the ‘agent’ to be used here?(switch_device ver.)

If I want to toggle SwitchA when 10 seconds have elapsed from the start of the game, what should I specify as the Agent?

In this case, there is no instigator to toggle the switch

The following code seems redundant(Sorry, Not tested.).

TeamCollection := GetPlayspace().GetTeamCollection()
if:
    Teams := TeamCollection.GetTeams()
    Agents := TeamCollection.GetAgents[Teams[0]]
    Agent := Agents[0]
then:
    SwitchA.ToggleState(Agent) #SwitchA : switch_device

Thank you.

1 Like

I’d probably do this, just grabbing the first player in the game:

if:
    Player:player = GetPlayspace().GetPlayers()[0]
    PlayerAgent:agent = agent[Player]
then:
    SwitchDevice.ToggleState(PlayerAgent)
1 Like

That will work.
Thanks!

1 Like

You don’t need to do PlayerAgent:agent = agent[Player] here btw - player inherits from agent, so it can be passed anywhere expecting an agent

2 Likes

Thank you!
Here’s the final ver.(And tested.)

if:
    Agent := GetPlayspace().GetPlayers()[0]
then:
    SwitchDevice.ToggleState(Agent)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.