BLOCK REFERENCE / OPERATORS

Operators

Math, comparisons, logic, randomness and text.

20 blocks

Abs

Reporter→ numberoperators_abs
Abs

Returns the absolute value of a number (removes its minus sign).

FieldWhat it means
ValuenumberNumber to convert. -5 becomes 5; positive numbers stay the same.Default: -5
ValuesocketNumber to convert. -5 becomes 5; positive numbers stay the same.Default: number, any

Add

Reporter→ numberoperators_add
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.

FieldWhat it means
AnumberFirst number.Default: 1
BnumberSecond number.Default: 1
AsocketFirst number.Default: number, any
BsocketSecond number.Default: number, any

And

Boolean→ booleanoperators_and
And

True when both conditions are true.

FieldWhat it means
AdropdownFirst condition. Plug in a boolean block, or pick true/false when nothing is connected.Options: true · false
BdropdownSecond condition. Plug in a boolean block, or pick true/false when nothing is connected.Options: true · false
AsocketFirst condition. Plug in a boolean block, or pick true/false when nothing is connected.Default: boolean
BsocketSecond 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

Reporter→ numberoperators_clamp
Clamp

Returns a number limited to stay between a minimum and a maximum.

FieldWhat it means
ValuenumberNumber to limit.Default: 5
MinnumberLower limit.Default: 0
MaxnumberUpper limit. If it is lower than min, the block returns min.Default: 10
ValuesocketNumber to limit.Default: number, any
MinsocketLower limit.Default: number, any
MaxsocketUpper 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

Boolean→ booleangame.compare
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.

FieldWhat it means
{…}textLeft value. Accepts templates such as {score}, {Player.hp} or {global.gold}.Default: {global.gold}
isdropdownComparison: =, !=, <, >, <= or >=.Options: = · != · < · > · <= · >=
{…}textRight value. Also accepts templates.Default: 10

Example {global.gold} >= 10 to unlock a shop item.

Divide

Reporter→ numberoperators_divide
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.

FieldWhat it means
AnumberDividend (number to divide).Default: 4
BnumberDivisor. If it is 0 the block returns 0 instead of failing.Default: 2
AsocketDividend (number to divide).Default: number, any
BsocketDivisor. If it is 0 the block returns 0 instead of failing.Default: number, any

Equal

Boolean→ booleanoperators_compare_equal
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.

FieldWhat it means
AnumberFirst value (number, text or true/false).Default: 1
BnumberSecond value.Default: 1
AsocketFirst value (number, text or true/false).Default: number, string, boolean, any
BsocketSecond value.Default: number, string, boolean, any

Greater

Boolean→ booleanoperators_compare_greater
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.

FieldWhat it means
AnumberNumber to test.Default: 2
BnumberNumber to compare against.Default: 1
AsocketNumber to test.Default: number, any
BsocketNumber to compare against.Default: number, any

Join Text

Reporter→ stringoperators_join_text
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.

FieldWhat it means
AtextText placed first. Numbers and true/false are converted to text.Default: Hello
BtextText placed right after a, with no space in between.Default: World
AsocketText placed first. Numbers and true/false are converted to text.Default: string, number, boolean, any
BsocketText 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

Boolean→ booleanoperators_compare_less
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.

FieldWhat it means
AnumberNumber to test.Default: 1
BnumberNumber to compare against.Default: 2
AsocketNumber to test.Default: number, any
BsocketNumber to compare against.Default: number, any

Max

Reporter→ numberoperators_max
Max

Returns the larger of two numbers.

FieldWhat it means
AnumberFirst number.Default: 0
BnumberSecond number.Default: 1
AsocketFirst number.Default: number, any
BsocketSecond number.Default: number, any

Min

Reporter→ numberoperators_min
Min

Returns the smaller of two numbers.

FieldWhat it means
AnumberFirst number.Default: 0
BnumberSecond number.Default: 1
AsocketFirst number.Default: number, any
BsocketSecond number.Default: number, any

Modulo

Reporter→ numberoperators_modulo
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.

FieldWhat it means
AnumberNumber to divide.Default: 5
BnumberDivisor. If it is 0 the block returns 0.Default: 2
AsocketNumber to divide.Default: number, any
BsocketDivisor. 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

Reporter→ numberoperators_multiply
Multiply

Returns the product of two numbers.

FieldWhat it means
AnumberFirst factor.Default: 2
BnumberSecond factor.Default: 2
AsocketFirst factor.Default: number, any
BsocketSecond factor.Default: number, any

Example Multiply a speed in pixels/second by Delta Time to get the distance to move this frame.

Not

Boolean→ booleanoperators_not
Not

True when the condition is false, and false when it is true.

FieldWhat it means
ValuedropdownCondition to invert. Plug in a boolean block, or pick true/false when nothing is connected.Options: true · false
ValuesocketCondition to invert. Plug in a boolean block, or pick true/false when nothing is connected.Default: boolean

Or

Boolean→ booleanoperators_or
Or

True when at least one of the two conditions is true.

FieldWhat it means
AdropdownFirst condition. Plug in a boolean block, or pick true/false when nothing is connected.Options: true · false
BdropdownSecond condition. Plug in a boolean block, or pick true/false when nothing is connected.Options: true · false
AsocketFirst condition. Plug in a boolean block, or pick true/false when nothing is connected.Default: boolean
BsocketSecond 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 %

Boolean→ booleangame.chance
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.

FieldWhat it means
percent {…}textChance 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

Reporter→ numberoperators_random_range
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.

FieldWhat it means
MinnumberLowest possible value.Default: 0
MaxnumberHighest possible value.Default: 10
MinsocketLowest possible value.Default: number, any
MaxsocketHighest possible value.Default: number, any

Round

Reporter→ numberoperators_round
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).

FieldWhat it means
ValuenumberNumber to round.Default: 1.5
ValuesocketNumber to round.Default: number, any

Subtract

Reporter→ numberoperators_subtract
Subtract

Returns the first number minus the second.

FieldWhat it means
AnumberNumber to subtract from.Default: 2
BnumberNumber to subtract.Default: 1
AsocketNumber to subtract from.Default: number, any
BsocketNumber to subtract.Default: number, any