Skip to content

NumberCurve

Global · NumberCurve · server and client scripts

NumberCurve creates an immutable curve of numbers over normalized time from 0 to 1, such as particle size or opacity over a particle's lifetime. To inspect a curve's points, see NumberCurve.

new

Function
new(points: { { Time: number, Value: number, Envelope: number? } }) -> NumberCurve

NumberCurve.new creates a curve from an array of 2 to 8 point tables { Time = t, Value = v, Envelope = e? }. The first point must be at time 0, the last at time 1, and times must be in non-decreasing order.

Example

-- Server script.
local pulse = NumberCurve.new({
    { Time = 0, Value = 0.2 },
    { Time = 0.5, Value = 1 },
    { Time = 1, Value = 0 },
})
print(#pulse.Points) -- prints 3

linear

Function
linear(a: number, b: number?) -> NumberCurve

NumberCurve.linear creates a constant curve at a or a linear ramp from a at time 0 to b at time 1.

Example

-- Server script.
local fadeOut = NumberCurve.linear(1, 0)
print(fadeOut.Points[1].Value, fadeOut.Points[2].Value) -- prints 1 0