Effects and camera
Particle effects
With the world permission, client scripts start particle effects from a preset and change any value:
effects.burst("explosion", hit.point, { color = color("#80c0ff"), count = 300 }) -- once, cleans itself up
local flame = effects.start("fire", torch.position, { rate = 40, size = 0.5 }) -- keeps going
flame:follow(torch, vec3(0, 0.4, 0))
flame:stop() -- stop emitting; particles in the air finish
flame:play()
flame:emit(50) -- a one-off extra puff
flame:destroy()| Preset | Looks like |
|---|---|
sparks | Hot orange sparks that fall |
smoke | Slow grey puffs that rise |
fire | Flickering flame |
glow | Soft light blobs |
dust | Brown clouds that settle |
explosion | A fast burst |
magic | Sparkles |
effects.presets() lists them.
| Option | Range | Description |
|---|---|---|
color, endColor | colour or "#rrggbb" | Colour at birth and at death (fades to transparent by default) |
size | 0.001–20 | Particle size in metres |
lifetime | 0.02–30 | Seconds each particle lives |
speed | 0–200 | Starting speed |
spread | 0–180 | Cone angle in degrees (180 is every direction) |
gravity | -10–10 | Pull down (negative rises) |
count | 0–2000 | Particles in a burst |
rate | 0–500 | Particles per second for a running effect |
additive | boolean | Glowing (true) or solid (false) blending |
texture | path | A picture from your mod as the particle |
In map definitions, the same options go under "effectOptions", with colours as "#rrggbb" strings. A mod may have 256 effects running at once.
Tip Try presets and options while you play: in the script editor's Console, pick a running mod of yours that has the
worldpermission and typeeffects.burst("magic", world.me(), { count = 200, color = color("#80c0ff") }).
Camera
With the camera permission:
camera.shake(0.15, 0.4) -- strength (roughly metres), seconds
camera.zoom(-20) -- narrow the view by 20 degrees
timer.after(2, function() camera.zoom(0) end)The player's comfort settings always win: if they turned camera shake off, it stays off, and the field of view stays within safe limits. Zoom is removed when your mod stops.