- Documentation
- Shared functions
- createParticleEmitter
Function
createParticleEmitter
Creates an emitter of moving particles simulated by the game: fire, smoke, sparks, snow, portals and anything you build from the settings. The fourth argument is a preset name or a settings table, the fifth overrides chosen fields of the preset. Returns a "particle" element that can be moved, attached and destroyed like any other. Called on the server, it creates an emitter every player sees.
Syntax
element createParticleEmitter(float x, float y, float z, string|table settings [, table overrides = nil])Arguments
xfloat- Position X.
yfloat- Position Y.
zfloat- Position Z.
settingsstring|table- A preset name (
"fire","smoke","sparks","fireflies","snow","rain","magic","vortex","confetti","hearts","bubbles","leaves","dust","firework") or a settings table. overridestable, optional = nil- Fields that replace the preset's settings.
Returns
The emitter or false for bad arguments.
Example
A campfire next to the player and a custom portal from a settings table. All fields are described in the Particles guide.
local x, y, z = getElementPosition(localPlayer)
local fire = createParticleEmitter(x + 2, y, z - 1, "fire", { rate = 60 })
local portal = createParticleEmitter(x - 4, y, z, {
sprite = "glow", shape = "ring", radius = 2,
rate = 120, max = 300, life = { 1, 1.6 },
orbit = 3, attract = 0.6, size = { 0.25, 0.05 },
colors = { tocolor(120, 200, 255), tocolor(160, 90, 255, 0) },
})
-- ognisko na placu, widoczne dla wszystkich graczy (także wchodzących później)
local fire = createParticleEmitter(2495, -1670, 12.5, "fire", { rate = 60 })
Notes
Physics on the game side. The game simulates and draws the particles of all emitters in one pass, so the script does nothing per frame.
See also
createParticleEffectA short effect: the emitter releases particles for the given time and removes itself once the last one fades. No need to destroy it. On the server, every player nearby sees the effect.setParticleEmitterSettingsChanges chosen settings of a running emitter (the same fields as increateParticleEmitter), the rest stays. Living particles pick up the new colour and size immediately.getParticlePresetsReturns the ready-made particle effects as a{ name = description }table.burstParticlesReleases the given number of particles at once, regardless ofrate: an explosion, a hit, a burst of confetti.attachElementsAttaches an element to another. The attached element moves and rotates together with the one it is attached to. An object attached to a vehicle is carried by the game in the same frame as the vehicle physics, so it stays exactly in place even at high speed and in turns.