Extended Globals
Lune Custom Build extends the standard Luau globals with additional utility functions.
Math Extensions
Section titled “Math Extensions”math.clamp
Section titled “math.clamp”Clamps a value between a minimum and maximum:
math.clamp(5, 0, 10) --> 5math.clamp(-5, 0, 10) --> 0math.clamp(15, 0, 10) --> 10math.lerp
Section titled “math.lerp”Linear interpolation between two values:
math.lerp(0, 100, 0.5) --> 50math.lerp(0, 100, 0.25) --> 25math.lerp(10, 20, 0.5) --> 15math.inverseLerp
Section titled “math.inverseLerp”Returns the interpolation factor for a value between min and max:
math.inverseLerp(0, 100, 50) --> 0.5math.inverseLerp(0, 100, 25) --> 0.25math.map
Section titled “math.map”Maps a value from one range to another:
math.map(5, 0, 10, 0, 100) --> 50math.map(0.5, 0, 1, 0, 255) --> 127.5math.sign
Section titled “math.sign”Returns the sign of a number (-1, 0, or 1):
math.sign(5) --> 1math.sign(-5) --> -1math.sign(0) --> 0math.roundTo
Section titled “math.roundTo”Rounds a number to a specified number of decimal places:
math.roundTo(3.14159, 2) --> 3.14math.roundTo(3.14159, 0) --> 3math.roundTo(123.456, 1) --> 123.5math.tau
Section titled “math.tau”The constant τ (tau) = 2π:
print(math.tau) --> 6.283185307179586Colored Warn
Section titled “Colored Warn”The warn function outputs colored text to stderr:
warn("Something unexpected happened")-- Prints in yellow: [WARN] Something unexpected happenedUUID Generation
Section titled “UUID Generation”uuid.v4
Section titled “uuid.v4”Generates a random UUID (version 4):
local id = uuid.v4()print(id) --> "550e8400-e29b-41d4-a716-446655440000"uuid.v7
Section titled “uuid.v7”Generates a time-ordered UUID (version 7):
local id = uuid.v7()print(id) --> "018d5f3c-a8e7-7000-8000-000000000000"Tip: Use
uuid.v7()when you need IDs that sort chronologically, such as for database primary keys.