BLOCK REFERENCE / OPERATORS
Operators
Math, comparisons, logic, randomness and text.
20 blocks
#Abs

Returns the absolute value of a number (removes its minus sign).
| Field | What it means |
|---|---|
Valuenumber | Number to convert. -5 becomes 5; positive numbers stay the same.Default: -5 |
Valuesocket | Number to convert. -5 becomes 5; positive numbers stay the same.Default: number, any |
#Add

Returns the sum of two numbers.
The result is always a decimal number, so 1 + 1 shows as 2.0 when printed or joined into text.
| Field | What it means |
|---|---|
Anumber | First number.Default: 1 |
Bnumber | Second number.Default: 1 |
Asocket | First number.Default: number, any |
Bsocket | Second number.Default: number, any |
#And

True when both conditions are true.
| Field | What it means |
|---|---|
Adropdown | First condition. Plug in a boolean block, or pick true/false when nothing is connected.Options: true · false |
Bdropdown | Second condition. Plug in a boolean block, or pick true/false when nothing is connected.Options: true · false |
Asocket | First condition. Plug in a boolean block, or pick true/false when nothing is connected.Default: boolean |
Bsocket | Second condition. Plug in a boolean block, or pick true/false when nothing is connected.Default: boolean |
Example Key Pressed? space And Is Grounded? to allow jumping only from the floor.
#Clamp

Returns a number limited to stay between a minimum and a maximum.
| Field | What it means |
|---|---|
Valuenumber | Number to limit.Default: 5 |
Minnumber | Lower limit.Default: 0 |
Maxnumber | Upper limit. If it is lower than min, the block returns min.Default: 10 |
Valuesocket | Number to limit.Default: number, any |
Minsocket | Lower limit.Default: number, any |
Maxsocket | Upper limit. If it is lower than min, the block returns min.Default: number, any |
Example Keep health between 0 and 100 after healing or taking damage.
#Compare values

True when two values or {templates} compare as chosen (=, !=, <, >, <=, >=).
If both sides are numbers they are compared as numbers. Otherwise they are compared as text ignoring case, and only = and != can be true.
| Field | What it means |
|---|---|
{…}text | Left value. Accepts templates such as {score}, {Player.hp} or {global.gold}.Default: {global.gold} |
isdropdown | Comparison: =, !=, <, >, <= or >=.Options: = · != · < · > · <= · >= |
{…}text | Right value. Also accepts templates.Default: 10 |
Example {global.gold} >= 10 to unlock a shop item.
#Divide

Returns the first number divided by the second.
Dividing by zero (or by a value extremely close to zero) returns 0 and does not stop the game.
| Field | What it means |
|---|---|
Anumber | Dividend (number to divide).Default: 4 |
Bnumber | Divisor. If it is 0 the block returns 0 instead of failing.Default: 2 |
Asocket | Dividend (number to divide).Default: number, any |
Bsocket | Divisor. If it is 0 the block returns 0 instead of failing.Default: number, any |
#Equal

True when both values are equal.
Numbers compare by value (1 equals 1.0). Text is compared exactly, including upper and lower case. The texts true, yes, on and 1 all count as true, and false, no, off and 0 as false, so 1 equals true.
| Field | What it means |
|---|---|
Anumber | First value (number, text or true/false).Default: 1 |
Bnumber | Second value.Default: 1 |
Asocket | First value (number, text or true/false).Default: number, string, boolean, any |
Bsocket | Second value.Default: number, string, boolean, any |
#Greater

True when the first number is greater than the second.
Both sides are read as numbers; text that is not a number counts as 0.
| Field | What it means |
|---|---|
Anumber | Number to test.Default: 2 |
Bnumber | Number to compare against.Default: 1 |
Asocket | Number to test.Default: number, any |
Bsocket | Number to compare against.Default: number, any |
#Join Text

Returns two values joined together as a single piece of text.
No space is added automatically, so include one in a if you need it. Numbers from math blocks appear with a decimal (2.0). This block only works in sockets that accept text or any value; in a number-only socket it gives 0.
| Field | What it means |
|---|---|
Atext | Text placed first. Numbers and true/false are converted to text.Default: Hello |
Btext | Text placed right after a, with no space in between.Default: World |
Asocket | Text placed first. Numbers and true/false are converted to text.Default: string, number, boolean, any |
Bsocket | Text placed right after a, with no space in between.Default: string, number, boolean, any |
Example Join Score: with Get Variable score and send it to Print.
#Less

True when the first number is less than the second.
Both sides are read as numbers; text that is not a number counts as 0.
| Field | What it means |
|---|---|
Anumber | Number to test.Default: 1 |
Bnumber | Number to compare against.Default: 2 |
Asocket | Number to test.Default: number, any |
Bsocket | Number to compare against.Default: number, any |
#Max

Returns the larger of two numbers.
| Field | What it means |
|---|---|
Anumber | First number.Default: 0 |
Bnumber | Second number.Default: 1 |
Asocket | First number.Default: number, any |
Bsocket | Second number.Default: number, any |
#Min

Returns the smaller of two numbers.
| Field | What it means |
|---|---|
Anumber | First number.Default: 0 |
Bnumber | Second number.Default: 1 |
Asocket | First number.Default: number, any |
Bsocket | Second number.Default: number, any |
#Modulo

Returns the remainder of dividing the first number by the second.
Works with decimals too. The result takes the sign of the divisor, so -1 modulo 3 is 2, which is handy for wrapping indexes.
| Field | What it means |
|---|---|
Anumber | Number to divide.Default: 5 |
Bnumber | Divisor. If it is 0 the block returns 0.Default: 2 |
Asocket | Number to divide.Default: number, any |
Bsocket | Divisor. If it is 0 the block returns 0.Default: number, any |
Example Check whether a number is even with Modulo by 2 inside Equal 0.
#Multiply

Returns the product of two numbers.
| Field | What it means |
|---|---|
Anumber | First factor.Default: 2 |
Bnumber | Second factor.Default: 2 |
Asocket | First factor.Default: number, any |
Bsocket | Second factor.Default: number, any |
Example Multiply a speed in pixels/second by Delta Time to get the distance to move this frame.
#Not

True when the condition is false, and false when it is true.
| Field | What it means |
|---|---|
Valuedropdown | Condition to invert. Plug in a boolean block, or pick true/false when nothing is connected.Options: true · false |
Valuesocket | Condition to invert. Plug in a boolean block, or pick true/false when nothing is connected.Default: boolean |
#Or

True when at least one of the two conditions is true.
| Field | What it means |
|---|---|
Adropdown | First condition. Plug in a boolean block, or pick true/false when nothing is connected.Options: true · false |
Bdropdown | Second condition. Plug in a boolean block, or pick true/false when nothing is connected.Options: true · false |
Asocket | First condition. Plug in a boolean block, or pick true/false when nothing is connected.Default: boolean |
Bsocket | Second condition. Plug in a boolean block, or pick true/false when nothing is connected.Default: boolean |
Example Key Pressed? left Or Key Pressed? a to support both arrow keys and WASD.
#Random chance %

True with the given probability, from 0 to 100 percent.
A new roll happens every time the block is checked, so inside On Update it rolls every frame.
| Field | What it means |
|---|---|
percent {…}text | Chance of being true, in percent. Accepts a {template}. Values are limited to 0-100; text that is not a number stops the game with an error.Default: 25 |
Example Random chance % 10 to make an attack critical.
#Random Range

Returns a random decimal number between a minimum and a maximum.
The result is not rounded (for example 3.72). Wrap it in Round for whole numbers, or use Calculate with random for an integer range. A new value is picked every time the block is evaluated.
| Field | What it means |
|---|---|
Minnumber | Lowest possible value.Default: 0 |
Maxnumber | Highest possible value.Default: 10 |
Minsocket | Lowest possible value.Default: number, any |
Maxsocket | Highest possible value.Default: number, any |
#Round

Returns a number rounded to the nearest whole number.
Exact halves round to the nearest even number: 1.5 becomes 2, but 2.5 also becomes 2. The result is still a decimal number (2.0).
| Field | What it means |
|---|---|
Valuenumber | Number to round.Default: 1.5 |
Valuesocket | Number to round.Default: number, any |
#Subtract

Returns the first number minus the second.
| Field | What it means |
|---|---|
Anumber | Number to subtract from.Default: 2 |
Bnumber | Number to subtract.Default: 1 |
Asocket | Number to subtract from.Default: number, any |
Bsocket | Number to subtract.Default: number, any |