The "approx" Function

Syntax#

approx(value, min, [max]);
ArgumentTypeDescription
valuerealThe numerical value to check
minrealThe minimum closeness, or alternatively, minimum value to accept
[max]realOptional: The maximum value to accept (use none for +/- min)

Description#

Checks if a value is between two numbers and returns true or false.

By default, the input value will be tested plus or minus the min value, but an explicit max value can also be supplied to set the exact range.

Example#

if (approx(enemy.x - x, 128)) {
//Enemy is near player on left or right
}