Effects with selectable colors

Hi im trying to make a stool that spawns an entity that spews out liquid.
But I can’t figure out how to the the effect’s particle’s colors depend on the rbg variables.

I have the color panel all set up and everything works out but I cant add the chosen color to the effect. Any ideas?

:smugdog:

Show us your code though and we may be able to help you.

just a note this is mainly for blood effects.

INIT
//Variables in init
ENT.speed = 1
ENT.r = 158
ENT.g = 43
ENT.b = 39

//Attempt to create effect with color

local DirVec = self.Entity:GetUp()

local effectdata = EffectData()
effectdata:SetOrigin( self.Entity:GetPos()+(self.Entity:GetUp())*7 ) 
effectdata:SetStart( self.Entity:GetPhysicsObject():GetVelocity())
effectdata:SetNormal(DirVec)
effectdata.r = ent.r
effectdata.g = ent.g
effectdata.b = ent.b
util.Effect( "AdvFX", effectdata )

EFFECT INIT (parts of importance)
function EFFECT:Init( data )
self.r = data.r
self.g = data.g
self.b = data.b

local particle = emitter:Add( “effects/smoke”, self.Position )

particle:SetColor( self.r, self.g, self.b)

says at line 59 in entity INIT: attempt to use global ent ( a nil value)
(something like that)

Never use the data table passed by EFFECT:Init as a normal table,because it will only stream to the client the data passed by the set/getters.
Instead,use the methods garry provided us.
So,you need to do in you sent
[lua]
effectdata:SetAngle(Angle(self.r,self.g,self.b))
util.Effect( “AdvFX”, effectdata )
[/lua]

and then in your EFFECT:INIT
[lua]
function EFFECT:Init(data)
self.r=self:GetAngle().p
self.g=self:GetAngle().y
self.b=self:GetAngle().r
[/lua]
I know,using the angle to send the rgb is dumb(there is no get/set color yet),but it works.

The error is here
[lua]
effectdata.r = ent.r
effectdata.g = ent.g
effectdata.b = ent.b
[/lua]
You are inside an ent function,you should call self.<value’s name> instead of ent.<value’s name>.
When the entity is initialised it will inherit all of the variables and functions you declare in the .lua file,and it will see those things only with the self pointer.