Built-in Types
Built-in types available in the game runtime.
Logical Types
Keyword | Type | Values |
| Boolean logic type |
|
Integer Types
Keyword | Type | Range | Example |
| 8-bit Signed Integer |
|
|
| 8-bit Unsigned Integer |
|
|
| 16-bit Signed Integer |
|
|
| 16-bit Unsigned Integer |
|
|
| 32-bit Signed Integer |
|
|
| 32-bit Unsigned Integer |
|
|
| 64-bit Signed Integer |
|
|
| 64-bit Unsigned Integer |
|
|
You can declare inline numbers using Cast<T>(value)
. It is useful for Int8
/Uint8
and Int16
/Uint16
for example:
Floating-Point Types
Keyword | Type | Range | Example |
| 32-bit Single-Precision | 6-9 significant decimal digits (more info) |
|
| 64-bit Double-Precision | 15-17 significant decimal digits (more info) |
|
Literal Types
Keyword | Type | Prefix | Example |
| Mutable character string |
| |
| Non-mutable string constant |
|
|
| Resource reference path |
|
|
| TweakDB Record ID |
|
|
String
values are stored internally as a null-terminated character array, unfortunately the bytecode doesn't support accessing the individual characters as an array.
CName
values are stored in-engine as a 64-bit hash key to a interned string pool. Class, function and field names are stored in the CName pool, so any methods that need a dynamic reference a scripted component will use a CName
value.
ResRef
values are similar to CName
values, except they specifically refer to archive resource files and presumably use a separate optimized string pool. Unlike CName
, ResRef
doesn't have any defined operators.
TweakDBID
is used as the primary key for all *_Record
types stored in TweakDB, the engine's internal database.
Other Types
Keyword | Type |
| A dynamic type that can store any other type |
Operators
The RED4 scripting runtime implements most operators as native functions. Only the equals ==
and not equals !=
operators are implemented in bytecode. The redscript compiler provides a number of operator symbols as shorthand.
This table lists the available operators (in precedence block order) and what types support them.
Type | Symbol | Logical | Integer | Float | String | CName | TweakDBID |
Negate |
| - | ✓ | ✓ | - | - | - |
Logical Not |
| ✓ | - | - | - | - | ✓¹ |
Bitwise Not |
| - | ✓ | - | - | - | - |
Multiplication |
| - | ✓ | ✓ | ✓² | - | - |
Division |
| - | ✓ | ✓ | - | - | - |
Modulo |
| - | ✓ | ✓ | - | - | - |
Addition |
| - | ✓ | ✓ | ✓³ | ✓⁴ | ✓⁴ |
Subtraction |
| - | ✓ | ✓ | - | - | - |
Less Than |
| - | ✓ | ✓ | - | - | - |
Less Than or Equal |
| - | ✓ | ✓ | - | - | - |
Greater Than |
| - | ✓ | ✓ | - | - | - |
Greater Than or Equal |
| - | ✓ | ✓ | - | - | - |
Equals |
| ✓ | ✓ | ✓ | ✓ | ✓⁵ | ✓ |
Not Equals |
| ✓ | ✓ | ✓ | ✓ | ✓⁵ | ✓ |
Logical And |
| ✓ | - | - | - | - | - |
Logical Or |
| ✓ | - | - | - | - | - |
Bitwise And |
| - | ✓ | - | - | - | - |
Bitwise Or |
| - | ✓ | - | - | - | - |
Bitwise Xor |
| - | ✓ | - | - | - | - |
Assign |
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Assign Add |
| - | ✓ | ✓ | ✓ | - | ✓ |
Assign Subtract |
| - | ✓ | ✓ | - | - | - |
Assign Multiply |
| - | ✓ | ✓ | - | - | - |
Assign Divide |
| - | ✓ | ✓ | - | - | - |
Assign Bitwise And |
| - | ✓ | - | - | - | - |
Assign Bitwise Or |
| - | ✓ | - | - | - | - |
Notes
The Logical Not
!
operator forTweakDBID
is overridden to return!TDBID.IsValid(a)
Strings can be multiplied by an
Int32
to repeat the string:String
addition is concatenation. There are native functions to allow most types can be concatenated withString
CName
andTweakDBID
addition is concatenation (and presumably involves some kind of internal lookup to a known value)The redscript compiler doesn't currently support the
==
and!=
symbols for theCName
type, use theEquals(a,b)
andNotEquals(a,b)
intrinsic functions for now.
Last updated