<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.trainzsimulator.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Valentinvladimirovic</id>
	<title>TrainzOnline - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.trainzsimulator.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Valentinvladimirovic"/>
	<link rel="alternate" type="text/html" href="https://wiki.trainzsimulator.com/wiki/Special:Contributions/Valentinvladimirovic"/>
	<updated>2026-11-05T11:47:35Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://wiki.trainzsimulator.com/index.php?title=Class_GameObject&amp;diff=9846</id>
		<title>Class GameObject</title>
		<link rel="alternate" type="text/html" href="https://wiki.trainzsimulator.com/index.php?title=Class_GameObject&amp;diff=9846"/>
		<updated>2017-04-30T22:15:39Z</updated>

		<summary type="html">&lt;p&gt;Valentinvladimirovic: Undo revision 3229 by Windwalkr (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[TrainzScript Language Russian]]&lt;br /&gt;
**[[Class GSObject|GSObject]]&lt;br /&gt;
***GameObject 2TE116U&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*GameObject is the base class for any object that requires messaging and threading support. &lt;br /&gt;
*GameObjects are placed in the game&#039;s object table, known as the Router. &lt;br /&gt;
*You cannot create a GameObject using &#039;&#039;new()&#039;&#039; from a script, all game objects are created by the game. &lt;br /&gt;
*Each game object has a unique ID (see [[#GetId|GetId()]]) and many also have a name. &lt;br /&gt;
*GameObject instances are often referred to as a &#039;&#039;node&#039;&#039; because they represent a message node in the Router. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==AddHandler==&lt;br /&gt;
{{MethodHeader|public native void AddHandler(GameObject target, string major, string minor, string Handler)}}&lt;br /&gt;
;Parameters&lt;br /&gt;
*&#039;&#039;&#039;target&#039;&#039;&#039; = Object to add the message handler to. This is usually &#039;&#039;me&#039;&#039; but can be any &#039;&#039;GameObject&#039;&#039;.&lt;br /&gt;
*&#039;&#039;&#039;major&#039;&#039;&#039; = Message &#039;&#039;major&#039;&#039; to listen for.&lt;br /&gt;
*&#039;&#039;&#039;minor&#039;&#039;&#039; = Message &#039;&#039;minor&#039;&#039; to listen for. If this paremeter is null or an empty string then all messages that match the &#039;&#039;major&#039;&#039; parameter will be sent to the handler.&lt;br /&gt;
*&#039;&#039;&#039;Handler&#039;&#039;&#039; Name of the message handler method to call. This must have a prototype in of the form &#039;&#039;void MessageHandler(Message msg)&#039;&#039;&lt;br /&gt;
;Returned Value&lt;br /&gt;
*None&lt;br /&gt;
;Syntax&lt;br /&gt;
 AddHandler(me,&amp;quot;Object&amp;quot;,&amp;quot;Enter&amp;quot;,&amp;quot;ObjectHandler&amp;quot;);&lt;br /&gt;
 AddHandler(me,&amp;quot;Object&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;ObjectHandler&amp;quot;);&lt;br /&gt;
;Notes&lt;br /&gt;
*Adds a message handler to the current class such that it will be called whenever the target GameObject receives a matching message.&lt;br /&gt;
*Message handlers called by this means are not threaded and will be executed immediately.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==ClearMessages==&lt;br /&gt;
{{MethodHeader|public native void ClearMessages(string major, string minor)}}&lt;br /&gt;
;Parameters&lt;br /&gt;
*&#039;&#039;&#039;major&#039;&#039;&#039; = Message &#039;&#039;major&#039;&#039; to listen for.&lt;br /&gt;
*&#039;&#039;&#039;minor&#039;&#039;&#039; = Message &#039;&#039;minor&#039;&#039; to listen for.&lt;br /&gt;
;Returned Value&lt;br /&gt;
*None&lt;br /&gt;
;Syntax&lt;br /&gt;
 ClearMessages(&amp;quot;Object&amp;quot;,&amp;quot;Enter&amp;quot;);&lt;br /&gt;
;Notes&lt;br /&gt;
*Clears any outstanding messages of the specified major and minor types that have been sent via calls to [[#PostMessage|PostMessage()]] and have not yet been processed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Exception==&lt;br /&gt;
{{MethodHeader|public native void Exception(string reason)}}&lt;br /&gt;
;Parameters&lt;br /&gt;
*&#039;&#039;&#039;reason&#039;&#039;&#039; = Explanatory text to add to the message box.&lt;br /&gt;
;Returned Value&lt;br /&gt;
*None&lt;br /&gt;
;Syntax&lt;br /&gt;
 Exception(&amp;quot;Fatal Error&amp;quot;);&lt;br /&gt;
;Notes&lt;br /&gt;
*Raises an Exception on the current thread and prints out the contents of the &#039;&#039;reason&#039;&#039; parameter followed by a stack dump.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==GetId==&lt;br /&gt;
{{MethodHeader|public native int GetId(void)}}&lt;br /&gt;
;Parameters&lt;br /&gt;
*None&lt;br /&gt;
;Returned Value&lt;br /&gt;
*The GameObject ID, an integer value which the Router uses to identify the current object.&lt;br /&gt;
;Syntax&lt;br /&gt;
 int ID = GetId();&lt;br /&gt;
;Notes&lt;br /&gt;
*The ID is unique to the current session.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==GetName==&lt;br /&gt;
{{MethodHeader|public native string GetName(void)&#039;&#039;&#039;}}&lt;br /&gt;
;Parameters&lt;br /&gt;
*None&lt;br /&gt;
;Returned Value&lt;br /&gt;
*The name of the current object if it has one, an empty string otherwise.&lt;br /&gt;
;Syntax&lt;br /&gt;
 string MyName = GetName();&lt;br /&gt;
;Notes&lt;br /&gt;
*The name returned is the text string that is shown at the top of the property object browser for the object concerned.&lt;br /&gt;
*If the name has been assigned by the game this will be the asset&#039;s username followed by a serial number.&lt;br /&gt;
*The string returned by this method is not guaranteed to be unique although TRS will issue prompts requesting confirmation in situations where duplication of names is about to occur.&lt;br /&gt;
*The name persists from session to session.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==PostMessage==&lt;br /&gt;
{{MethodHeader|public native void PostMessage(GameObject dest, string major, string minor, float seconds)}}&lt;br /&gt;
;Parameters&lt;br /&gt;
*&#039;&#039;&#039;dest&#039;&#039;&#039; = Destination object for the message. If this is null the message will be broadcast.&lt;br /&gt;
*&#039;&#039;&#039;major&#039;&#039;&#039; = Message &#039;&#039;major&#039;&#039; to be sent. &lt;br /&gt;
*&#039;&#039;&#039;minor&#039;&#039;&#039; = Message &#039;&#039;minor&#039;&#039; to be sent.&lt;br /&gt;
*&#039;&#039;&#039;seconds&#039;&#039;&#039; = Delay in seconds before the message is posted. If this is zero the message will be posted immediately.&lt;br /&gt;
;Returned Value&lt;br /&gt;
*None&lt;br /&gt;
;Syntax&lt;br /&gt;
 PostMessage(me,&amp;quot;Timer&amp;quot;,&amp;quot;Tick&amp;quot;,10.0); &lt;br /&gt;
 PostMessage(null,&amp;quot;Browser-URL&amp;quot;,&amp;quot;live://next&amp;quot;,0.0);&lt;br /&gt;
;Notes&lt;br /&gt;
*Messages sent via this method are processed by the Router in the next game update after they become due.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==SendMessage==&lt;br /&gt;
{{MethodHeader|public native void SendMessage(GameObject dest, string major, string minor)}}&lt;br /&gt;
;Parameters&lt;br /&gt;
*&#039;&#039;&#039;dest&#039;&#039;&#039; = Destination object for the message. If this is null the message will be broadcast.&lt;br /&gt;
*&#039;&#039;&#039;major&#039;&#039;&#039; = Message &#039;&#039;major&#039;&#039; to be sent. &lt;br /&gt;
*&#039;&#039;&#039;minor&#039;&#039;&#039; = Message &#039;&#039;minor&#039;&#039; to be sent.&lt;br /&gt;
;Returned Value&lt;br /&gt;
*None&lt;br /&gt;
;Syntax&lt;br /&gt;
 SendMessage(train,&amp;quot;Object&amp;quot;,&amp;quot;Enter&amp;quot;);&lt;br /&gt;
;Notes&lt;br /&gt;
*Sends a message to the destination object for immediate processing.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Sleep==&lt;br /&gt;
{{MethodHeader|public native void Sleep(float seconds)}}&lt;br /&gt;
;Parameters&lt;br /&gt;
*&#039;&#039;&#039;seconds&#039;&#039;&#039; = Time to wait in seconds.&lt;br /&gt;
;Returned Value&lt;br /&gt;
*None&lt;br /&gt;
;Syntax&lt;br /&gt;
 Sleep(10.0);&lt;br /&gt;
;Notes&lt;br /&gt;
*Causes the current thread to pause for the specified period of time.&lt;br /&gt;
*Warning! Sleep(World.PlaySound(...)) should no longer be used, as PlaySound does not return the file duration anymore!&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Sniff==&lt;br /&gt;
{{MethodHeader|public native void Sniff(GameObject target, string major, string minor, bool state)}}&lt;br /&gt;
;Parameters&lt;br /&gt;
*&#039;&#039;&#039;target&#039;&#039;&#039; = Game Object to which the handler will be attached.&lt;br /&gt;
*&#039;&#039;&#039;major&#039;&#039;&#039; = Message &#039;&#039;major&#039;&#039; to listen for.&lt;br /&gt;
*&#039;&#039;&#039;minor&#039;&#039;&#039; = Message &#039;&#039;minor&#039;&#039; to listen for. If this parameter is null or an empty string then all messages matching the &#039;&#039;major&#039;&#039; parameter will be processed.&lt;br /&gt;
*&#039;&#039;&#039;state&#039;&#039;&#039; = Boolean flag to set whether or not the handler is currently active.&lt;br /&gt;
;Returned Value&lt;br /&gt;
*None&lt;br /&gt;
;Syntax&lt;br /&gt;
 Sniff(train,&amp;quot;Object&amp;quot;,&amp;quot;Enter&amp;quot;,true);&lt;br /&gt;
;Notes&lt;br /&gt;
*Attaches a message handler to another object allowing the current script to listen in on the specified messages.&lt;br /&gt;
*Messages of the specified type received by the target object will be copied to the current script.&lt;br /&gt;
*The current script will usually need a separate handler to process these messages and will normally need to check the identity of the message source.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Code Examples==&lt;br /&gt;
Script calls made during the Init() method of an object can never be certain that other objects within the map have already been initialised. In cases where initialisation depends on the existence of other objects [[#PostMessage|PostMessage()]] can be used to delay part or all of the startup.  Messages sent in this way are never processed until the next game update and this does not occur until all objects have been initialised.&lt;br /&gt;
 public void Init(void)&lt;br /&gt;
 {&lt;br /&gt;
    inherited();&lt;br /&gt;
    SetupTasks();&lt;br /&gt;
    AddHandler(me,&amp;quot;Setup&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;SetupHandler&amp;quot;);&lt;br /&gt;
    PostMessage(me,&amp;quot;Setup&amp;quot;,&amp;quot;&amp;quot;,0.0);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void SetupHandler(Message msg)&lt;br /&gt;
 {&lt;br /&gt;
    if(msg.major == &amp;quot;Setup&amp;quot; and msg.src == me)&lt;br /&gt;
    {&lt;br /&gt;
       MoreSetupTasks();&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Related Methods==&lt;br /&gt;
[[Class Router#GetGameObject|Router.GetGameObject()]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[Class Router#PostMessage|Router.PostMessage()]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[TrainzScript Message Reference]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Categories==&lt;br /&gt;
[[Category:Script Class]]&lt;br /&gt;
&lt;br /&gt;
----&lt;/div&gt;</summary>
		<author><name>Valentinvladimirovic</name></author>
	</entry>
	<entry>
		<id>https://wiki.trainzsimulator.com/index.php?title=File:119.jpg&amp;diff=9143</id>
		<title>File:119.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.trainzsimulator.com/index.php?title=File:119.jpg&amp;diff=9143"/>
		<updated>2016-10-06T12:24:53Z</updated>

		<summary type="html">&lt;p&gt;Valentinvladimirovic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Valentinvladimirovic</name></author>
	</entry>
	<entry>
		<id>https://wiki.trainzsimulator.com/index.php?title=File:Helpmode1.jpg&amp;diff=8459</id>
		<title>File:Helpmode1.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.trainzsimulator.com/index.php?title=File:Helpmode1.jpg&amp;diff=8459"/>
		<updated>2015-08-16T17:43:55Z</updated>

		<summary type="html">&lt;p&gt;Valentinvladimirovic: Valentinvladimirovic uploaded a new version of &amp;amp;quot;File:Helpmode1.jpg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Valentinvladimirovic</name></author>
	</entry>
</feed>