Hello! I have some problems in TRS19 with searching of GameObjects.
Primary, I want to show you what I have in a code:
1.
2.
Of course I have declaration of variable allSgn and in a function meaning of its:
And variables take on meanings like this:
For sure variables like this is a "Signal" kind.
The things I need to do:
1. Seeking of a lot of signals and junctions on a huge route.
2. Changing variables inside these signals.
3. Changing directions of junctions.
4. And these all are for interlocking of the route. I need to do my own, because there is an especial interlocking systems in Russia. It's not universal, just for my own route and because of this I have to find all necessary junctions and signals by its names, because it will not change ever.
Circumstances I have:
1. For sure code is correct, because on a small test route it's completely workable.
2. On a huge route there is an error: NULL_reference while I am trying to change something inside these variables.
3. The main thing! The error NULL_reference is not every time, it's 50% only. One time it works, another is not.
This is a mini-map of my route for now(it will rise):
Is there something I have to do for making this search correct in 100%?
Primary, I want to show you what I have in a code:
1.
Code:
public NamedObjectInfo[] SynchronouslyGetNamedObjectList(string categoryFilter, string zhel1) {
AsyncObjectSearchResult asyncSearch = World.GetNamedObjectList(categoryFilter, zhel1);
Sniff(asyncSearch, "ObjectSearch", "AsyncResult", true);
Message msg;
wait()
{
on "ObjectSearch", "AsyncResult", msg:
if (msg.src == asyncSearch)
break;
continue;
};
int errCode = asyncSearch.GetSearchErrorCode();
if (errCode != AsyncObjectSearchResult.ERROR_NONE)
Interface.Print("RDSjunction.SynchronouslyGetNamedObjectList> Search failed, error: " + errCode);
return asyncSearch.GetResults();
}
2.
Code:
Signal FindSignalByName (string SignalName) {
int i;
for (i = 0; i < allSgn.size (); i++)
{
if (allSgn[i].localisedUsername == SignalName)
return cast<Signal>allSgn[i].objectRef;
}
return null;
}
Of course I have declaration of variable allSgn and in a function meaning of its:
Code:
allSgn = SynchronouslyGetNamedObjectList(AssetCategory.Signal, "");
And variables take on meanings like this:
Code:
sign_n = FindSignalByName ("zhel_n");
The things I need to do:
1. Seeking of a lot of signals and junctions on a huge route.
2. Changing variables inside these signals.
3. Changing directions of junctions.
4. And these all are for interlocking of the route. I need to do my own, because there is an especial interlocking systems in Russia. It's not universal, just for my own route and because of this I have to find all necessary junctions and signals by its names, because it will not change ever.
Circumstances I have:
1. For sure code is correct, because on a small test route it's completely workable.
2. On a huge route there is an error: NULL_reference while I am trying to change something inside these variables.
3. The main thing! The error NULL_reference is not every time, it's 50% only. One time it works, another is not.
This is a mini-map of my route for now(it will rise):
Is there something I have to do for making this search correct in 100%?
Last edited: