Types: Difference between revisions
From TrainzOnline
Jump to navigationJump to search
No edit summary |
m Add links between language reference pages |
||
| (3 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
{{MethodHeader|bool}} | * [[TrainzScript Language Reference]] | ||
** [[Comments & Delineation]] | |||
** [[TrainzScript Keywords]] | |||
** [[Operators]] | |||
** [[Types]] | |||
<br /> | |||
== Types == | |||
{{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 15: | ||
<br> | <br> | ||
{{MethodHeader|int}} | {{anchor|int}}{{MethodHeader|int}} | ||
*32 bit integer | *32 bit integer | ||
*Range from -2147483647 .. 2147483647 | *Range from -2147483647 .. 2147483647 | ||
| Line 13: | Line 22: | ||
+100 | +100 | ||
-100 | -100 | ||
0x0f (Tested only in T:ANE) | |||
<br> | <br> | ||
{{MethodHeader|float}} | {{anchor|float}}{{MethodHeader|float}} | ||
*32 bit floating number | *32 bit floating number | ||
Formats | Formats | ||
| Line 24: | Line 33: | ||
<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 52: | ||
<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 | ||
| 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 14:08, 28 December 2020
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