Hi! I am a beginner in Verse. How do I call the function if I want to subscribe to it as is? Like if I don’t want to create a trigger?
Like this:
Code
Teams(Agent:agent):void =
TeamCollection := GetPlayspace().GetTeamCollection()
if:
AgentsTeam := TeamCollection.GetTeam[Agent]
then:
TeamsArray := TeamCollection.GetTeams()
for (TeamNumber->Team : TeamsArray):
if (AgentsTeam = Team):
Print(“This is team {TeamNumber}”)
if (TeamNumber = 0):
Print(“This is team 1”)
else if (TeamNumber = 1):
Print(“This is team 2”)
And then when I want to call it, what do I write in the brackets?
bear in mind im no expert and this is only what i believe to be true i’m sure there are better ways of doing this so please chime in if i’m wrong or there is a better way
for your function to work you need to pass it an agent
you get the agent from the player or ai
so you create a variable MyAgent then you need to tell verse what that varible is
if you want to identify a specific agent you need to have a way telling verse how to find it then you can set it to MyAgent then call your function using Teams(MyAgent)
eg
Players := GetPlayspace().GetPlayers()
for (MyAgent : Players):
Teams(MyAgent)
this will pass all the agents in the Players array to your function, but you probaly need a way of identifing which agent is the agent you want to pass to your function
by using a trigger all this work is done for you and the agent is passed to your function via the Subscribe