Molang

YSM Molang reference: Math functions

Every Molang function and variable you can use in Yes Steve Model animations and controllers, with what it returns and the YSM version that added it. New to Molang? Start with Molang in YSM.

MolangWhat it doesSince
math.piPi (π), constantFixed at 3.141592653589791.1.5
math.eEuler's number (e), constantFixed at 2.718281828459041.1.5
math.floor(value)Round value down to the nearest integer1.1.5
math.round(value)Round value to the nearest integer1.1.5
math.ceil(value)Round value up to the nearest integer1.1.5
math.trunc(value)Truncate value to an integer (rounds towards zero, which rounds up for negative numbers)1.1.5
math.clamp(value, min, max)Clamp value between min and max1.1.5
math.max(x, y)Return the maximum of x and y1.1.5
math.min(x, y)Return the minimum of x and y1.1.5
math.abs(value)Absolute value of value1.1.5
math.exp(value)Exponential function of value with base e ($e^{value}$)1.1.5
math.ln(value)Natural logarithm of value (base e)1.1.5
math.sqrt(value)Square root of value1.1.5
math.mod(value, denominator)Remainder of value divided by denominator1.1.5
math.pow(base, exponent)Return base raised to the power of exponent1.1.5
math.sin(value)Sine of valueInput is in degrees1.1.5
math.cos(value)Cosine of valueInput is in degrees1.1.5
math.acos(value)Arccosine of valueInput value range is [-1, 1], returns radians1.1.5
math.asin(value)Arcsine of valueInput value range is [-1, 1], returns radians1.1.5
math.atan(value)Arctangent of valueInput value range is [-∞, +∞], returns radians1.1.5
math.atan2(y, x)Angle (in radians) between the positive x-axis and the ray from (0,0) to (x,y)1.1.5
math.lerp(start, end, 0_to_1)Linearly interpolate between start and end via 0_to_1Equivalent to: $start + (end - start) \times 0\_to\_1$1.1.5
math.lerprotatee(start, end, 0_to_1)Interpolate angle between start and end via 0_to_1Wraps around to 0 when exceeding 360 degrees1.1.5
math.random(low, high)Return a random number between low and high1.1.5
math.random_integer(low, high)Return a random **integer** between low and high1.1.5
math.die_roll(num, low, high)Return the sum of num random numbers, each ranging from low to highGenerated numbers are **not** integers like normal dice. Use math.die_roll_integer for that.1.1.5
math.die_roll_integer(num, low, high)Return the sum of num random integers, each ranging from low to highGenerated numbers are integers, like normal dice1.1.5
math.hermite_blend(value)Smooth curve interpolation using a Hermite function: $3 \times value^{2} - 2 \times value^{3}$While any valid float is a valid input, this works best in the [0, 1] range1.1.5
math.min_angle(value)Wrap an angle into the equivalent [-180, 180) rangeRemoves extra full rotations from the input angle to keep it within [-180, 180]1.2.0
math.randomi(value)Same as math.random_integerNon-standard naming, for original GeckoLib compatibility only1.1.5
math.roll(value)Same as math.die_rollNon-standard naming, for original GeckoLib compatibility only1.1.5
math.rolli(value)Same as math.die_roll_integerNon-standard naming, for original GeckoLib compatibility only1.1.5
math.hermite(value)Same as math.hermite_blendNon-standard naming, for original GeckoLib compatibility only1.1.5