[Solved] Can't get Color3 from ParticleEmitter.Color (a ColorSequence)

ParticleEmitter.Color returns a ColorSequence.

ColorSequence is inadequatly documented. “It returns an array of the colors…” An array? When printed it prints 0 1 1 1 0 1 1 1 1 0 for 2 white colors. AKA [0 1 1 1 0],[1 1 1 1 0] What are the objects in the array? Had to do some serious digging and it’s this:

ColorSequenceKeyPoint. It doesn’t exist in ObjectBrowser or the wiki.
It only exists in Intellisense. What are its properties? .Color, .r,.g,.b all error. When printed, it prints 0 1 1 1 0 for a white color.

I wrote this hacky tostring code in the meantime:

function colorseq(seq)
	seq = tostring(seq)
	local pattern = "[^%s,]+"
	local r1,g1,b1 = 0,0,0
	local i = 0
	for match in seq:gmatch(pattern) do
		i = i + 1
		if i == 2 then
	    	r1 = match
		elseif i == 3 then
			g1 = match
		elseif i == 4 then
			b1 = match
		end
	end
	return Color3.new(r1,g1,b1)
end

print( colorseq(workspace.ParticleEmitter.Color.Keypoints[1]) )
print( colorseq(workspace.ParticleEmitter.Color.Keypoints[2]) )

I assume it’s something like:
Time R G B something Time R G B something …

In your case, you would have:

  • 1,1,1 at time 0 with something 0
  • 1,1,1 at time 1 with something 0

Also after some experimenting, ColorSequenceKeypoints have the following properties that I know of:

  • Time: The timestamp
  • Value: The Color3
    Can’t get that third value that’s always 0…
    I think it’s what’s the Envelope for a NumberSequence.
    It’s probably the same structure internally, but exposed to Lua they hid .Envelope (if that exists)

I guess that’s all you wanted, though?

2 Likes

This should be documented on the wiki. I’ll log it on the system.

1 Like

Added those properties to the wiki under the ColorSequence’s page.
(ColorSequenceKeyframe will redirect to that section, for convenience)

3 Likes

It’s not ColorSequenceKeyframe, it’s ColorSequenceKeypoint. The rest is correct, it’s float Time, Color3 Value, float Envelope. The latter is reserved because I still am deciding on what it should do for colors.

1 Like

Well, seems like I derped majorly with the name.

When I tried guessing properties, Envelope was one of my guesses, but it errored about not being a member.
Do you mean with “reserved” it is added, but not yet visible from Lua?

Yes, it exists within the C++ class, it’s saved to place/model files, it’s replicated across the network, but it doesn’t do anything yet, so it’s not exposed in Lua. Reserved it before we shipped the emitter, so that we don’t have to change the serialization/replication protocols later facing “old client + new server” sort of problems.

I guessed it was because the NumberSequence etc actually uses the Envelope thing.
Along with that, I assumed it internally had the same data class, but one of them hadn’t it exposed to the Lua.
So that’s more or less the case.

What could Envelope be used for in a ColorSequence?
Will we be allowed to have more than 2 colors later on?
Envelope, does it mean it’ll randomise the color a tiny bit?