Types

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
(added anchors)
m (Added info on Hex notation for int)
Line 13: Line 13:
 
  +100
 
  +100
 
  -100
 
  -100
  hex?
+
  0x0f (Tested only in T:ANE)
 
<br>
 
<br>
  

Revision as of 05:01, 20 September 2016

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


Personal tools