Types

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
(added anchors)
m (Add links between language reference pages)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
* [[TrainzScript Language Reference]]
 +
** [[Comments & Delineation]]
 +
** [[TrainzScript Keywords]]
 +
** [[Operators]]
 +
** [[Types]]
 +
<br />
 +
 +
== Types ==
 +
 
{{anchor|bool}}{{MethodHeader|bool}}
 
{{anchor|bool}}{{MethodHeader|bool}}
 
*Contains the Boolean constants ''true'' or ''false''
 
*Contains the Boolean constants ''true'' or ''false''
Line 13: Line 22:
 
  +100
 
  +100
 
  -100
 
  -100
  hex?
+
  0x0f (Tested only in T:ANE)
 
<br>
 
<br>
  
Line 55: Line 64:
 
  Numbers[0,1] = null;                      // deletes the first value from the array, decreasing its size by 1
 
  Numbers[0,1] = null;                      // deletes the first value from the array, decreasing its size by 1
 
<br>
 
<br>
 +
 +
 +
=Categories=
 +
[[Category:TrainzScript]]

Latest revision as of 00:08, 29 December 2020


[edit] Types

bool
  • Contains the Boolean constants true or false
  • Casting an integer of value 0 to a bool will result in false, any other value will result in true.
!false = true
(bool) 0 = false


int
  • 32 bit integer
  • Range from -2147483647 .. 2147483647
Formats
100
+100
-100
0x0f (Tested only in T:ANE)


float
  • 32 bit floating number
Formats
1.0
1.0f
polish notation?


object
  • object is a base class which may be used to store references to objects of any class.


string
  • Strings can be indexed as arrays.
  • Strings support the following escape sequences
\r   ?
\n   New line
\t   Tab character
\l   ?
\a   ?
\b   ?
\\   Backslash
\"   Double quote mark
\'   Single quote mark
\0   ?


Array Types
  • Arrays are indexed lists of any base type or any class type including GameObjects.
  • Arrays are declared using these statements
Train[] trains;
int[] Numbers = new int[n]; // where n is the number of items in the array.
  • The keyword new creates the array but does not initialise any of the members
Numbers[3] = 256; // assigns a value to the array. Array indices start at zero
  • Arrays may also be returned by methods
Signal[] signals = World.GetSignalList()  // creates an array of signals from a built in method
Numbers[Numbers.size()] = 5;              // adds a new value after the end of the array, increasing its size by 1
Numbers[0,1] = null;                      // deletes the first value from the array, decreasing its size by 1



[edit] Categories

Personal tools