Luawe All pages

range2

Number ranges: a min and a max. A range can be changed, like a table: two names for one range see the same one.

range2.newfunction

range2.new(min: number, max: number): range2

A number range from min to max: range2.new(1, 6). Given the wrong way round, they are put in order (range2.new(6, 1) is 1 to 6).

ValueType
minnumber
maxnumber

Gives: range2.

range2.minfunction

r.min: number

Its smallest number. Set past max, max moves with it.

range2.maxfunction

r.max: number

Its biggest number. Set below min, min moves with it.

range2:lerpfunction

r:lerp(t: number): number

The number t of the way from min (t = 0) to max (t = 1), as math.lerp.

ValueType
tnumber

Gives: number.

range2:clampfunction

r:clamp(x: number): number

x kept inside the range: min when it is below, max when it is above.

ValueType
xnumber

Gives: number.

range2:containsfunction

r:contains(x: number): boolean

Is x inside the range (min and max count)?

ValueType
xnumber

Gives: boolean.

range2:randomfunction

r:random(): number

A random number inside the range.

Gives: number.

range2.changedfunction

r.changed: event

An event that happens when one of its numbers changes.