Sounds somewhat mystic? Not at all. (;-) And at the end of that all I learned, that to avoid trouble with this "Zero"-GOID issue, it is necessary to use for the initial tasks a message handler for the "World", "ModuleInit'' message and NOT the Init, SetProperties and GetProperties methods. And additionally it may be a good idea to first add for every kind of object one will use in the route layer an unscripted (!) object (or with harmless Init, SetProperties and GetProperties methods) to exhaust this "Zero"-GOID's.
In some posts I searched for some backgrounds with the Init, SetProperties and GetProperties methods in conjunction with a scriptlibrary. To test that, I added to each of the methods a InterfaceLog method to see if the methods were executed. I logged the position and the GOID of the "me"-object.
The first sudden and unwanted result: In a empty, new created route/session pair with no one object, the preview of my asset logs the Init and the SetProperties log with the GOID "0,3,0,0," (here is 3 for scenery objects I think, 4 was used for the script library asset/object).
And if in this method some things like counting an object group or one time activating a dependent object or so, this isn't a good idea, because the result may be unwanted. Please remember this. I'll come back to this later.
Somewhere in the fields we may read that the GOID is unique over save/load cycles of the route/session. And for this the next sudden result appeared: Adding the object instance to the route layer shows me the same GOID for the object in the route layer ("0,3,0,0,") and the logs too.
Adding a second instance brings the next sudden thing: It gets the GOID "0,3,2,0,". Ok, another GOID as expected, but why not one? Trainz has its reasons, and of capital importance is the different GOID. And to tell it here early: The route-layer group uses even running numbers and the session layer group the odd ones.
But resuming my path I prepared the next two sudden result:
First I deleted the object with the "Zero"-GOID and it logged the GetProperties method. Don't know the reason, but Trainz should know. In order to avoid the question: At the end I post the script I used for my scenery object; it has additionally two attachment points to show the GOID at the object too.
Second, I switched to driver with ctrl-F2. And the just deleted object logs as a ghost. And the "Zero"-GOID-Ghost stays alive after storing the route/session. However when I start the session or the route in driver (directly or by switching), the ghost stays alive and logs his logs and hence executes the methods. Advantageous is the fact that the ghost will use the current script of the asset.
Thinking back, I remember that there were some issues with ghost vehicles in the past. I myself had the case where the steam of the loco retained visible, but the loco itself did not after derailing and disappearing. And one case was with the diesel steam after deleting the running loco while switching to surveyor. I don't remember what I did to solve this and I was not able to repeat this issue. So in my eyes it may be such a case with "Zero"-GOID?
To solve this issue by N3V it seems to me to be necessary to start the GOID running numbers in the router-layer with two and not with zero and save the "Zero"-GOID for the previews.
And until then it would be nice to have a set of harmless assets, one for every GOID-Group, minimum for Route/Session creators, associated with some more knowledge about the count of GOID-Groups Trainz uses.
The following script should run with any kind of asset. In some cases if the method still exists, it is necessary to add the needed parts of the script to the existing for test purposes.
If someone is interested to get my test asset, please PM me an I will give you a temporary link to the zip file containing the cdp and original folder for private use.
A screenshot with the log from starting into driver and and a scene picture you will find here: screenshot
In some posts I searched for some backgrounds with the Init, SetProperties and GetProperties methods in conjunction with a scriptlibrary. To test that, I added to each of the methods a InterfaceLog method to see if the methods were executed. I logged the position and the GOID of the "me"-object.
The first sudden and unwanted result: In a empty, new created route/session pair with no one object, the preview of my asset logs the Init and the SetProperties log with the GOID "0,3,0,0," (here is 3 for scenery objects I think, 4 was used for the script library asset/object).
And if in this method some things like counting an object group or one time activating a dependent object or so, this isn't a good idea, because the result may be unwanted. Please remember this. I'll come back to this later.
Somewhere in the fields we may read that the GOID is unique over save/load cycles of the route/session. And for this the next sudden result appeared: Adding the object instance to the route layer shows me the same GOID for the object in the route layer ("0,3,0,0,") and the logs too.
Adding a second instance brings the next sudden thing: It gets the GOID "0,3,2,0,". Ok, another GOID as expected, but why not one? Trainz has its reasons, and of capital importance is the different GOID. And to tell it here early: The route-layer group uses even running numbers and the session layer group the odd ones.
But resuming my path I prepared the next two sudden result:
First I deleted the object with the "Zero"-GOID and it logged the GetProperties method. Don't know the reason, but Trainz should know. In order to avoid the question: At the end I post the script I used for my scenery object; it has additionally two attachment points to show the GOID at the object too.
Second, I switched to driver with ctrl-F2. And the just deleted object logs as a ghost. And the "Zero"-GOID-Ghost stays alive after storing the route/session. However when I start the session or the route in driver (directly or by switching), the ghost stays alive and logs his logs and hence executes the methods. Advantageous is the fact that the ghost will use the current script of the asset.
Thinking back, I remember that there were some issues with ghost vehicles in the past. I myself had the case where the steam of the loco retained visible, but the loco itself did not after derailing and disappearing. And one case was with the diesel steam after deleting the running loco while switching to surveyor. I don't remember what I did to solve this and I was not able to repeat this issue. So in my eyes it may be such a case with "Zero"-GOID?
To solve this issue by N3V it seems to me to be necessary to start the GOID running numbers in the router-layer with two and not with zero and save the "Zero"-GOID for the previews.
And until then it would be nice to have a set of harmless assets, one for every GOID-Group, minimum for Route/Session creators, associated with some more knowledge about the count of GOID-Groups Trainz uses.
The following script should run with any kind of asset. In some cases if the method still exists, it is necessary to add the needed parts of the script to the existing for test purposes.
Code:
include "MapObject.gs"
//---------------------------------------------------------------------------
// Object V1 Dummy <kuid2:215489:999990:1>
//---------------------------------------------------------------------------
class zerogoid isclass MapObject
{
//-------------------------------------------------------------------------
// Global variable for objects soup
//-------------------------------------------------------------------------
GameObjectID goid = me.GetGameObjectID();
int value = 100;
string stext = "souptext";
//-------------------------------------------------------------------------
// Mandatory init method
//-------------------------------------------------------------------------
public void Init(Asset asset)
{
inherited(asset);
//-----------------------------------------------------------------------
// Set asset special initial values and methods
//-----------------------------------------------------------------------
AddHandler(me, "World", "ModuleInit", "ModuleInitHandler");
//-----------------------------------------------------------------------
// Show the goid on both sides of me
//-----------------------------------------------------------------------
SetFXNameText("GOIDV","[D]["+goid.SerialiseToString()+"]");
SetFXNameText("GOIDH","[D]["+goid.SerialiseToString()+"]");
//-----------------------------------------------------------------------
// Log the init method is finished
//-----------------------------------------------------------------------
Interface.Log(Interface.GetTimeStamp()+" INIT FINISHED"
+ " GOID [" + goid.SerialiseToString() + "]");
//-----------------------------------------------------------------------
}
//-------------------------------------------------------------------------
void ModuleInitHandler(Message msg)
{
//---------------------------------------------------------------------
// Log the handler method was called
//---------------------------------------------------------------------
int curmod = World.GetCurrentModule();
string timestamp = Interface.GetTimeStamp();
string modul = "NONE";
if (curmod == World.DRIVER_MODULE) modul="DRIVER";
if (curmod == World.SURVEYOR_MODULE) modul="SURVEYOR";
Interface.Log(timestamp + " WORLD MODULE INIT [" + modul + "]"
+ " GOID [" + goid.SerialiseToString() + "]");
//---------------------------------------------------------------------
}
//-------------------------------------------------------------------------
public void SetProperties(Soup soup) // Callback method after Init method
{
inherited(soup);
//-----------------------------------------------------------------------
// Load values from soup
//-----------------------------------------------------------------------
value = soup.GetNamedTagAsInt("value",200);
stext = soup.GetNamedTag("text");
if (stext=="") stext="starttext";
//-----------------------------------------------------------------------
// Log the setproperties method is finished
//-----------------------------------------------------------------------
Interface.Log(Interface.GetTimeStamp()+" SETPROPS FINISHED"
+ " GOID [" + goid.SerialiseToString() + "]");
//-----------------------------------------------------------------------
}
//-------------------------------------------------------------------------
public Soup GetProperties(void) // Callback method before closing session
{
Soup soup = inherited();
//-----------------------------------------------------------------------
// Store values to soup
//-----------------------------------------------------------------------
soup.SetNamedTag("value",value);
soup.SetNamedTag("text",stext);
//-----------------------------------------------------------------------
// Log the getproperties method is finished
//-----------------------------------------------------------------------
Interface.Log(Interface.GetTimeStamp()+" GETPROPS FINISHED"
+ " GOID [" + goid.SerialiseToString() + "]");
//-----------------------------------------------------------------------
return soup;
}
};
If someone is interested to get my test asset, please PM me an I will give you a temporary link to the zip file containing the cdp and original folder for private use.
A screenshot with the log from starting into driver and and a scene picture you will find here: screenshot

Last edited: