Sending color to an effect via an entity

I use this code to create following effect:
[lua]
local smoke = EffectData()
smoke:SetOrigin(self:GetPos())
smoke:SetColor(self:GetColor())
util.Effect(“effect_smoke”, smoke)
[/lua]

But it just tell me a lua error
[lua]
bad argument #1 to ‘SetColor’ (number expected, got table)
[/lua]

How can I send a color to an effect without creating a lua error?

Please check the wiki page for the function before asking questions:

As far as I can tell, you need to convert the color into a number, where the first byte of an integer is the red, second - green, third blue and fourth - alpha channel.

You will need to use the bit library for this.

Already read that, but didnt understood how to bring it to paper.

Here’s something I whipped up but I can’t test it right now, so I am not sure if it works.




local clr = Color( 50, 100, 150, 255 )

local r = bit.band( clr.r, 255 )
local g = bit.band( clr.g, 255 )
local b = bit.band( clr.b, 255 )
local a = bit.band( clr.a, 255 )

local numberClr = bit.lshift( r, 24 ) + bit.lshift( r, 16 ) + bit.lshift( r, 8 ) + a


Hey, thanks.
This works great.