particles
The particles namespace — the engine's Luau API reference for particles.
The particles namespace — 5 functions.
globals/particles/create
particles.create(spec: table?) -> any
Create a GPU particle system from a spec, allocating its buffers and
registering it with the auto-update driver. The handle it returns carries
:emit, :update, the setters, and :observe.
Parameters
spectable(optional) —{ maxCount, rate, lifetime, speed, shape, ... }— every field optional, each falling back to the emitter's default.
Returns any — The particle system handle.
local fire = particles.create({ maxCount = 2000, rate = 100 })
globals/particles/list
particles.list() -> { any }
Every particle system this VM has created and not destroyed, in creation order. Answered from the emitter registry, so finding an emitter costs nothing per entity in the scene.
Returns { any } — table Array of particle system handles.
for _, sys in ipairs(particles.list()) do print(sys:getActiveCount()) end
globals/particles/observe
particles.observe(system: any?) -> { [string]: any }
What the engine is simulating and drawing for particles right now.
With no argument, every live emitter plus the totals they sum to; with an
emitter, that one's reading. An engine holding no emitters answers
count = 0 with an empty list, which reads differently from an engine
whose emitters are all silent (count > 0, silent = count).
Parameters
systemany(optional) — Optional particle system handle to read on its own.
Returns { [string]: any } — table The observation.
local o = particles.observe(); print(o.count, o.alive, o.silent)
local r = particles.observe(fire); print(r.alive, r.bytes.total)
globals/particles/silenceReasons
particles.silenceReasons() -> { { reason: string, means: string } }
The closed set of reasons an emitter can be producing nothing, in the
order a reading resolves them — nearest cause first — each with what it
means. Every observe().reason is one of these.
Returns { { reason: string, means: string } } — table Array of { reason, means }.
for _, r in ipairs(particles.silenceReasons()) do print(r.reason, r.means) end
globals/particles/whySilent
particles.whySilent(system: any?) -> (string?, string?)
Why one emitter is producing nothing, from the closed set
silenceReasons() enumerates — or nil when it is producing. The second
return is the detail line naming what the reason is about.
Parameters
systemany(optional) — The particle system handle to ask about.
Returns (string?, string?) — string? The reason, or nil. string? The detail line for that reason.
local why, detail = particles.whySilent(fire)