Luawe All pages

range3

Number ranges with a number inside them: min, current and max, like a health bar. A range can be changed, like a table.

range3.newfunction

range3.new(min: number, current: number, max: number): range3

A number range with a number inside it, like a health bar: local health = range3.new(0, 100, 100), then health.current -= 20. current always stays from min to max.

ValueType
minnumber
currentnumber
maxnumber

Gives: range3.

range3.minfunction

r.min: number

Its smallest number. Set past max, max moves with it; current stays inside.

range3.currentfunction

r.current: number

The number inside it. Set outside, it stops at min or max.

range3.maxfunction

r.max: number

Its biggest number. Set below min, min moves with it; current stays inside.

range3.fractionfunction

r.fraction: number

How far current is from min to max, from 0 to 1: health.fraction * 4 is how wide a 4-tile health bar is. Set it to put current there.

range3: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.

range3:clampfunction

r:clamp(x: number): number

x kept inside the range.

ValueType
xnumber

Gives: number.

range3:containsfunction

r:contains(x: number): boolean

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

ValueType
xnumber

Gives: boolean.

range3:randomfunction

r:random(): number

A random number inside the range.

Gives: number.

range3.changedfunction

r.changed: event

An event that happens when one of its numbers changes: health.changed:connect(function() bar.width = health.fraction * 4 end).