Types
From TrainzOnline
(Difference between revisions)
(added anchors) |
|||
Line 1: | Line 1: | ||
− | {{MethodHeader|bool}} | + | {{anchor|bool}}{{MethodHeader|bool}} |
*Contains the Boolean constants ''true'' or ''false'' | *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''. | *Casting an integer of value 0 to a bool will result in ''false'', any other value will result in ''true''. | ||
Line 6: | Line 6: | ||
<br> | <br> | ||
− | {{MethodHeader|int}} | + | {{anchor|int}}{{MethodHeader|int}} |
*32 bit integer | *32 bit integer | ||
*Range from -2147483647 .. 2147483647 | *Range from -2147483647 .. 2147483647 | ||
Line 16: | Line 16: | ||
<br> | <br> | ||
− | {{MethodHeader|float}} | + | {{anchor|float}}{{MethodHeader|float}} |
*32 bit floating number | *32 bit floating number | ||
Formats | Formats | ||
Line 24: | Line 24: | ||
<br> | <br> | ||
− | {{MethodHeader|object}} | + | {{anchor|object}}{{MethodHeader|object}} |
*''object'' is a base class which may be used to store references to objects of any class. | *''object'' is a base class which may be used to store references to objects of any class. | ||
<br> | <br> | ||
Line 43: | Line 43: | ||
<br> | <br> | ||
− | {{MethodHeader|Array Types}} | + | {{anchor|Array}}{{MethodHeader|Array Types}} |
*Arrays are indexed lists of any base type or any class type including GameObjects. | *Arrays are indexed lists of any base type or any class type including GameObjects. | ||
*Arrays are declared using these statements | *Arrays are declared using these statements |
Revision as of 10:09, 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