Number
Syntax¶
Any identifier starting with a digit or a period (.) will be treated as a number. Numbers can also contain underscores between digits which can provide visual clarity without affecting the value of the number.
The compiler will not prevent you from including more than 3 decimal places in a number, however the extra digits will be truncated when processed by DiamondFire due to its precision limit.
If you absolutely require higher precision numbers, your best bet is to use Vectors, although Vectors cannot take advantage of Set Variable actions that operate on numbers.
Raw %math Expressions¶
When writing equations, it is highly recommended to use Terracotta's powerful Expression system instead of raw %math expressions. However, in cases where you need very fine control over compiled output, number values with arbitrary characters (e.g. %math expressions) can be created by putting n before a string. The contents of the string will be placed directly into the number value.
Operations¶
+ (Addition)¶
num + num: num¶
Adds the left and right Numbers together.
num + str: str¶
Converts the Number into a String and adds it onto the String.
num + txt: txt¶
Converts the left Number into a String then adds it at the beginning of the right Styled Text.
- (Subtraction)¶
num - num: num¶
Subtracts the right Number from the left Number.
* (Multiplication)¶
num * num: num¶
Multiplies the two Numbers together.
vec * num: vec¶
Multiplies the length of the Vector by the Number.
/ (Division)¶
num / num: num¶
Divides the left Number by the right Number.
vec / num: vec¶
Divides the Vector and the Number.
** (Exponentiation)¶
num ** num: num¶
Raises the left Number to the power of the right Number.
% (Remainder)¶
num % num: num¶
Returns the remainder after dividing the left Number by the right Number.
%% (Modulus)¶
num %% num: num¶
Returns the modulus of the left Number and the right Number.
Bitwise Operations¶
The following bitwise operators can be used on numbers:
&: And|: Or^: Exclusive Or<<: Left Shift>>: Right shift>>>: Unsigned Right Shift~: Not (used as a prefix, similar to!)
To use the enhanced precision versions of bitwise operations, put a ^ at the start of the operator.
(e.g. ^& is precise AND, ^^ is precise XOR, ^>>> is precise unsigned right shift)