Skip to main content

Functions: Math

Kahuna provides the following mathematical functions to support arithmetic operations within scripts:

FunctionDescriptionExample
abs(x)Returns the absolute value of xabs(-10)10
ceil(x)Rounds x up to the nearest whole numberceil(3.2)4
floor(x)Rounds x down to the nearest whole numberfloor(3.8)3
round(x)Rounds x to the nearest whole numberround(4.5)5
max(a, b)Returns the maximum of a and bmax(7, 3)7
min(a, b)Returns the minimum of a and bmin(7, 3)3
clamp(x, a, b)Clamps x to be within the range [a, b]clamp(10, 0, 5)5
sqrt(x)Returns the square root of xsqrt(16)4
pow(x, y)Returns x raised to the power of ypow(2, 3)8

These functions are useful for implementing game logic, conditional updates, or business rules directly inside Kahuna Scripts.