Types
From TrainzOnline
(Difference between revisions)
m (1 revision) |
|||
Line 28: | Line 28: | ||
<br> | <br> | ||
− | {{MethodHeader|string}} | + | {{anchor|string}}{{MethodHeader|string}} |
*Strings can be indexed as arrays. | *Strings can be indexed as arrays. | ||
*Strings support the following escape sequences | *Strings support the following escape sequences |
Revision as of 10:07, 31 October 2010
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 hex?
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