-
Notifications
You must be signed in to change notification settings - Fork 0
NativeTypes
| Keyword | Type | Values |
|---|---|---|
Bool |
Boolean logic type |
truefalse
|
EBOOL |
Enum-based nullable bool |
UNINITIALZED = 0FALSE = 1TRUE = 2
|
EBOOL seems to only be used by the Cooldown system and as a m_isInitialized field in class ScriptedPuppetPS
(presumably legacy code from older RED engine games)
| Keyword | Type | Range |
|---|---|---|
Int8 |
Currently unsupported by the compiler | |
Uint8 |
Currently unsupported by the compiler | |
Int16 |
Currently unsupported by the compiler | |
Uint16 |
Currently unsupported by the compiler | |
Int32 |
32-bit Signed Integer |
−2,147,483,648 to 2,147,483,647
|
Uint32 |
32-bit Unsigned Integer |
0 to 4,294,967,295
|
Int64 |
64-bit Signed Integer |
−9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
|
Uint64 |
64-bit Unsigned Integer |
0 to 18,446,744,073,709,551,615
|
| Keyword | Type | Range |
|---|---|---|
Float |
32-bit Single-Precision | 6-9 significant decimal digits (more info) |
Double |
64-bit Double-Precision | 15-17 significant decimal digits (more info) |
| Keyword | Type | Prefix | Example |
|---|---|---|---|
String |
Mutable character string | "Hello world" |
|
CName |
Non-mutable character string | n |
n"VehicleComponent" |
ResRef |
Resource reference path | r |
r"base\\anim_cooked.cookedanims" |
TweakDBID |
TweakDB Record ID | t |
t"Items.RequiredItemStats" |
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.
They are represented internally using a composite hash key made from:
- A CRC-32 hash of the record's name,
- A byte storing the name length, and
- 3 bytes for storing the offset of a value within that record
| Keyword | Type |
|---|---|
Variant |
A dynamic type that can store any other type |
The RED4 scripting runtime implements most operators as native functions (presumably for speed purposes).
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 | none⁶ | - | ✓ | - | - | - | - |
| Assign Bitwise Or | none⁶ | - | ✓ | - | - | - | - |
- The Logical Not
!operator forTweakDBIDis overridden to return!TDBID.IsValid(a) - Strings can be multiplied by an
Int32to repeat the string:public static func OperatorMultiply(a: String, count: Int32) -> String
-
Stringaddition is concatenation. There are native functions to allow most types can be concatenated withString -
CNameandTweakDBIDaddition 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 theCNametype, use theEquals(a,b)andNotEquals(a,b)intrinsic functions for now. - These functions aren't currently supported by symbol, but native functions exist for each integer type:
public static native func OperatorAssignAnd(out a: Uint64, b: Uint64) -> Uint64 public static native func OperatorAssignOr(out a: Uint64, b: Uint64) -> Uint64