<?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=Granthes</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=Granthes"/>
	<link rel="alternate" type="text/html" href="https://wiki.trainzsimulator.com/wiki/Special:Contributions/Granthes"/>
	<updated>2026-11-05T09:37:58Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://wiki.trainzsimulator.com/index.php?title=Types&amp;diff=9113</id>
		<title>Types</title>
		<link rel="alternate" type="text/html" href="https://wiki.trainzsimulator.com/index.php?title=Types&amp;diff=9113"/>
		<updated>2016-09-19T19:01:57Z</updated>

		<summary type="html">&lt;p&gt;Granthes: Added info on Hex notation for int&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{anchor|bool}}{{MethodHeader|bool}}&lt;br /&gt;
*Contains the Boolean constants &#039;&#039;true&#039;&#039; or &#039;&#039;false&#039;&#039;&lt;br /&gt;
*Casting an integer of value 0 to a bool will result in &#039;&#039;false&#039;&#039;, any other value will result in &#039;&#039;true&#039;&#039;.&lt;br /&gt;
 !false = true&lt;br /&gt;
 (bool) 0 = false&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{anchor|int}}{{MethodHeader|int}}&lt;br /&gt;
*32 bit integer&lt;br /&gt;
*Range from -2147483647 .. 2147483647&lt;br /&gt;
 Formats&lt;br /&gt;
 100&lt;br /&gt;
 +100&lt;br /&gt;
 -100&lt;br /&gt;
 0x0f (Tested only in T:ANE)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{anchor|float}}{{MethodHeader|float}}&lt;br /&gt;
*32 bit floating number&lt;br /&gt;
 Formats&lt;br /&gt;
 1.0&lt;br /&gt;
 1.0f&lt;br /&gt;
 polish notation?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{anchor|object}}{{MethodHeader|object}}&lt;br /&gt;
*&#039;&#039;object&#039;&#039; is a base class which may be used to store references to objects of any class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{anchor|string}}{{MethodHeader|string}}&lt;br /&gt;
*Strings can be indexed as arrays.&lt;br /&gt;
*Strings support the following escape sequences&lt;br /&gt;
 \r   ?&lt;br /&gt;
 \n   New line&lt;br /&gt;
 \t   Tab character&lt;br /&gt;
 \l   ?&lt;br /&gt;
 \a   ?&lt;br /&gt;
 \b   ?&lt;br /&gt;
 \\   Backslash&lt;br /&gt;
 \&amp;quot;   Double quote mark&lt;br /&gt;
 \&#039;   Single quote mark&lt;br /&gt;
 \0   ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{anchor|Array}}{{MethodHeader|Array Types}}&lt;br /&gt;
*Arrays are indexed lists of any base type or any class type including GameObjects.&lt;br /&gt;
*Arrays are declared using these statements&lt;br /&gt;
 Train[] trains;&lt;br /&gt;
 int[] Numbers = new int[n]; // where &#039;&#039;n&#039;&#039; is the number of items in the array.&lt;br /&gt;
*The keyword &#039;&#039;new&#039;&#039; creates the array but does not initialise any of the members&lt;br /&gt;
 Numbers[3] = 256; // assigns a value to the array. Array indices start at zero&lt;br /&gt;
*Arrays may also be returned by methods&lt;br /&gt;
 Signal[] signals = World.GetSignalList()  // creates an array of signals from a built in method&lt;br /&gt;
 Numbers[Numbers.size()] = 5;              // adds a new value after the end of the array, increasing its size by 1&lt;br /&gt;
 Numbers[0,1] = null;                      // deletes the first value from the array, decreasing its size by 1&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Granthes</name></author>
	</entry>
	<entry>
		<id>https://wiki.trainzsimulator.com/index.php?title=Class_GSTrackSearch&amp;diff=2277</id>
		<title>Class GSTrackSearch</title>
		<link rel="alternate" type="text/html" href="https://wiki.trainzsimulator.com/index.php?title=Class_GSTrackSearch&amp;diff=2277"/>
		<updated>2011-06-07T04:41:21Z</updated>

		<summary type="html">&lt;p&gt;Granthes: /* Code Examples */ Typo on the GetDistance(); method&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[TrainzScript Language Reference|API Hierarchy]]&lt;br /&gt;
**GSTrackSearch&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*A class enabling the searching of a length of track for [[class Trackside|Trackside]] items. &lt;br /&gt;
*The GSTrackSearch class provides an interface to access certain items along a track in a specified direction from an existing trackside item. &lt;br /&gt;
*A GSTrackSearch object can be obtained by calling the [[Class Trackside#BeginTrackSearch|BeginTrackSearch()]] method on the [[class Trackside|Trackside]] item that you want to start your search from. &lt;br /&gt;
*The SearchNext() and GetMapObject() methods are provided to get a reference to a discovered [[class Trackside|Trackside]] object.&lt;br /&gt;
*The reference returned by these methods can be cast to [[class Trackside|Trackside]] child classes to find out if that item is in fact a [[class Signal|Signal]] or a [[class Junction|Junction]] for instance. As the script code doesn&#039;t know what the next item will be, always verify the cast. &lt;br /&gt;
*Since [[class Vehicle|Vehicles]] and [[Class Locomotive|Locomotives]] descend from [[class Trackside|Trackside]], searches can be initiated from rolling stock and rolling stock will be returned.&lt;br /&gt;
*GSTrackSearch methods will also find [[Class SceneryWithTrack|SceneryWithTrack]] and descendants, although the information which can be obtained from them is limited and these objects cannot be used to initiate a search.&lt;br /&gt;
*The search will continue (following the direction set by any junctions) until it is blocked by:&lt;br /&gt;
**A junction set against the track&lt;br /&gt;
**A turntable.&lt;br /&gt;
**A crossing. *** ? &amp;quot;crossing&amp;quot; appears to mean a track (diamond, etc), rather than a road (grade, level) crossing, since the function appears to work properly across road crossings. &lt;br /&gt;
**The end of the line.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*See [[TrackSearch]] for details of enhancements being developed for future versions of the game.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Trackside.BeginTrackSearch==&lt;br /&gt;
{{MethodHeader|public native GSTrackSearch Trackside.BeginTrackSearch(bool direction)}}&lt;br /&gt;
*This method is called on objects descending from the [[class Trackside|Trackside]] class to obtain a GSTrackSearch object in the specified search direction.&lt;br /&gt;
*See [[Class Trackside#BeginTrackSearch|Trackside.BeginTrackSearch()]] for details.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==GetDistance==&lt;br /&gt;
{{MethodHeader|public native float GetDistance(void)}}&lt;br /&gt;
;Parameters&lt;br /&gt;
*None&lt;br /&gt;
;Returned Value&lt;br /&gt;
*The distance in metres from the origin of the search to the object at which the search cursor is currently pointing.&lt;br /&gt;
;Syntax&lt;br /&gt;
 float distance = gst.GetDistance();&lt;br /&gt;
;Notes&lt;br /&gt;
*See [[#Code Examples|Code Examples]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==GetFacingRelativeToSearchDirection==&lt;br /&gt;
{{MethodHeader|public native bool GetFacingRelativeToSearchDirection(void)}}&lt;br /&gt;
;Parameters&lt;br /&gt;
*None&lt;br /&gt;
;Returned Value&lt;br /&gt;
*True if the returned object orientation matches the direction of search, false otherwise.&lt;br /&gt;
;Syntax&lt;br /&gt;
 bool facing = gst.GetFacingRelativeToSearchDirection();&lt;br /&gt;
;Notes&lt;br /&gt;
*Note that it is the direction of the search that matters, not the facing direction of the search origin.&lt;br /&gt;
*A search forwards from a fixed object such as a [[Class Trigger|Trigger]] will return &#039;&#039;&#039;true&#039;&#039;&#039; for any returned trigger which has the same orientation as the source. &lt;br /&gt;
*A search backwards from a fixed object such as a [[Class Trigger|Trigger]] will return &#039;&#039;&#039;false&#039;&#039;&#039; for any returned trigger which has the same orientation as the source. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==GetMapObject==&lt;br /&gt;
{{MethodHeader|public native MapObject GetMapObject(void)}}&lt;br /&gt;
;Parameters&lt;br /&gt;
*None&lt;br /&gt;
;Returned Value&lt;br /&gt;
*A reference to a MapObject or null if nothing has been found.&lt;br /&gt;
;Syntax&lt;br /&gt;
 MapObject mo = gst.GetMapObject();&lt;br /&gt;
;Notes&lt;br /&gt;
*MapObject returns Trackside descendants including Vehicles and SceneryWithTrack descendants including Industries.&lt;br /&gt;
*Ensure that you attempt a cast to SceneryWithTrack and Trackside if you want the maximum possible amount of information from the search.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==SearchNext==&lt;br /&gt;
{{MethodHeader|public native MapObject SearchNext(void)}}&lt;br /&gt;
;Parameters&lt;br /&gt;
*None&lt;br /&gt;
;Returned Value&lt;br /&gt;
*A reference to a MapObject or null if nothing has been found.&lt;br /&gt;
;Syntax&lt;br /&gt;
 MapObject mo = gst.GetMapObject();&lt;br /&gt;
;Notes&lt;br /&gt;
*SearchNext moves the search cursor to the next object if such an object exists.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Known Issues==&lt;br /&gt;
*GSTrackSearch will return a null reference if it finds certain types of [[Class Crossing|Crossing]] objects, but will continue searching beyond them if asked.  As a result of this it is often necessary to make repeated calls to SearchNext following a null return to decide whether you have reached the end of the track or whether your search has simply been interrupted by one or more crossings.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Code Examples==&lt;br /&gt;
*This code fragment implements a search forwards from a locomotive. The distance from the locomotive to any discovered object is printed to &#039;&#039;jetlog.txt&#039;&#039;&lt;br /&gt;
*The process continues until the search returns a null value (which might be a crossing or the end of the track) or the distance from the train exceeds 1km.&lt;br /&gt;
 GSTrackSearch gst = Loco.BeginTrackSearch(true);          // obtain a GSTrackSearch object&lt;br /&gt;
 MapObject mo = gst.SearchNext();                          // initiate the search&lt;br /&gt;
 while (mo) {                                              // continue as long as objects are present&lt;br /&gt;
   float distance = gst.GetDistance();                      // how far ahead the object is&lt;br /&gt;
   if (distance() &amp;gt; 1000.0) break;                         // break from the loop if the distance exceeds 1km&lt;br /&gt;
   Interface.Print(&amp;quot;object found at &amp;quot; distance &amp;quot; metres&amp;quot;); // print out the results&lt;br /&gt;
   mo = gst.SearchNext();                                  // search for the next object&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Related Methods==&lt;br /&gt;
[[Class Trackside#BeginTrackSearch|Trackside.BeginTrackSearch()]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Categories==&lt;br /&gt;
[[Category:Script Class]]&lt;/div&gt;</summary>
		<author><name>Granthes</name></author>
	</entry>
</feed>