How can I read the y of an X in a number sequence?

I tried looking at the documentation for number sequences, however I found nothing for what I want to do.

As an example, let’s say I have a number sequence with two key points in X = 0, x =. 5 and X = 1.
Now lets say I want to take the value in 0.25. How would I accomplish this?

There probably isn’t a function for it, however, you can probably calculate it using the slope of the first 2 points 0 and 0.5

Shouldn’t there be a function for it?

I’ve used the evalNS which has worked for me.

function evalNS(ns, time)
	-- If we are at 0 or 1, return the first or last value respectively
	if time == 0 then return ns.Keypoints[1].Value end
	if time == 1 then return ns.Keypoints[#ns.Keypoints].Value end
	-- Step through each sequential pair of keypoints and see if alpha
	-- lies between the points' time values.
	for i = 1, #ns.Keypoints - 1 do
		local this = ns.Keypoints[i]
		local next = ns.Keypoints[i + 1]
		if time >= this.Time and time < next.Time then
			-- Calculate how far alpha lies between the points
			local alpha = (time - this.Time) / (next.Time - this.Time)
			-- Evaluate the real value between the points using alpha
			return (next.Value - this.Value) * alpha + this.Value
		end
	end
end

local y = evalNS(someNumberSequence, 0.25)
4 Likes

There definitely should be.

Thanks!