Revision Difference
CLuaEmitter:Add#547367
<function name="Add" parent="CLuaEmitter" type="classfunc">
<description>Creates a new <page>CLuaParticle</page> with the given material and position.</description>
<realm>Client</realm>
<args>
<arg name="material" type="string">The particles material. Can also be an <page>IMaterial</page>.</arg>
<arg name="position" type="Vector">The position to spawn the particle on.</arg>
</args>
<rets>
<ret name="" type="CLuaParticle">The created particle, if any.</ret>
</rets>
</function>
⤶
⤶
⤶
<example>⤶
<description>Creates a simple spark particle effect 100 units above where the local player is looking at.</description>⤶
<code>⤶
local tr = LocalPlayer():GetEyeTrace()⤶
local pos = tr.HitPos + tr.HitNormal * 100 -- The origin position of the effect⤶
⤶
local emitter = ParticleEmitter( pos ) -- Particle emitter in this position⤶
⤶
for i = 0, 100 do -- Do 100 particles⤶
local part = emitter:Add( "effects/spark", pos ) -- Create a new particle at pos⤶
if ( part ) then⤶
part:SetDieTime( 1 ) -- How long the particle should "live"⤶
⤶
part:SetStartAlpha( 255 ) -- Starting alpha of the particle⤶
part:SetEndAlpha( 0 ) -- Particle size at the end if its lifetime⤶
⤶
part:SetStartSize( 5 ) -- Starting size⤶
part:SetEndSize( 0 ) -- Size when removed⤶
⤶
part:SetGravity( Vector( 0, 0, -250 ) ) -- Gravity of the particle⤶
part:SetVelocity( VectorRand() * 50 ) -- Initial velocity of the particle⤶
end⤶
end⤶
⤶
emitter:Finish()⤶
</code>⤶
⤶
</example>