Update particles.lua
This commit is contained in:
1 parent
7d43d65058
commit
86487de62d
1 file changed
+21
-11
@@ -27,20 +27,30 @@ end
|
|||||||
--- @return number|nil ptfxHandle -- The handle of the particle effect, or nil if it failed to create.
|
--- @return number|nil ptfxHandle -- The handle of the particle effect, or nil if it failed to create.
|
||||||
function Particle.Create(dict, ptfx, pos, rot, scale, color, looped, loopLength)
|
function Particle.Create(dict, ptfx, pos, rot, scale, color, looped, loopLength)
|
||||||
LoadPtfxAsset(dict)
|
LoadPtfxAsset(dict)
|
||||||
CreateThread(function()
|
UseParticleFxAssetNextCall(dict)
|
||||||
UseParticleFxAssetNextCall(dict)
|
SetParticleFxNonLoopedColour(color.x, color.y, color.z)
|
||||||
SetParticleFxNonLoopedColour(color.x, color.y, color.z)
|
local particle = nil
|
||||||
if looped then
|
if looped then
|
||||||
StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false)
|
particle = StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false)
|
||||||
|
CreateThread(function()
|
||||||
if loopLength then
|
if loopLength then
|
||||||
Wait(loopLength)
|
Wait(loopLength)
|
||||||
RemoveParticleFxInRange(pos.x, pos.y, pos.z, 0.01)
|
Particle.Remove(particle)
|
||||||
end
|
end
|
||||||
else
|
end)
|
||||||
StartParticleFxNonLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false)
|
else
|
||||||
end
|
particle = StartParticleFxNonLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false)
|
||||||
RemoveNamedPtfxAsset(ptfx)
|
end
|
||||||
end)
|
|
||||||
|
return particle
|
||||||
|
end
|
||||||
|
|
||||||
|
function Particle.Remove(particle)
|
||||||
|
if not particle then return end
|
||||||
|
StopParticleFxLooped(particle, false)
|
||||||
|
RemoveParticleFx(particle, false)
|
||||||
|
RemoveNamedPtfxAsset(particle)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Particle.CreateOnEntity(dict, ptfx, entity, offset, rot, scale, color, looped, loopLength)
|
function Particle.CreateOnEntity(dict, ptfx, entity, offset, rot, scale, color, looped, loopLength)
|
||||||
|
|||||||
Reference in new issue
Block a user