Hi
I would like to know the best way of looping - or 'browsing' you might call it - through a collection of nodes within the server.
Suppose I have a server called "Footballteam" and I have a node of type "Player" with property "Name" and a node of type "Goal" with property "Scoredby". Futher on I have a (non-hierarical) reference called "PlayerHasscoredGoal".
Now I do the following:
Add 20 nodes of Players
Add 60 nodes of Goals
Then I want to do something like :
foreach Player in Footballteam
foreach Goal in Footballteam
if (Player.Name == Goal.Scoredby)
AddReference PlayerHasscoredGoal to Player that referes to Goal
What is the best way to do this? One solution I would think of is to make a flat list of objectnodes with Players and Goals at the point of adding the nodes to the server and put some information in the Userdata. Then looping the flat lists. Another way I can imagine is to browse the nodes in a ServerInternalClient and to add the references there. Both methods have their disadvantages. Is there a easier way ?
Kind regards
Nico
Looping through nodes within the server
Moderator: uasdknet
-
- Hero Member
- Posts: 23
- Joined: 23 Aug 2013, 09:30
- Support Team
- Hero Member
- Posts: 3068
- Joined: 18 Mar 2011, 15:09
Re: Looping through nodes within the server
Hi Nico,
I assume you have loaded the nodes into memory with CreateObject/CreateVariable?
If this is the case the best approach would add the reference when you add the Goal object with a call to AddReference.
This approach would work if the Goals are added in method or callback function.
Best regards
Support Team
I assume you have loaded the nodes into memory with CreateObject/CreateVariable?
If this is the case the best approach would add the reference when you add the Goal object with a call to AddReference.
This approach would work if the Goals are added in method or callback function.
Best regards
Support Team