Coming soon toSteam
Modding docsAPI 1

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()
PresetLooks like
sparksHot orange sparks that fall
smokeSlow grey puffs that rise
fireFlickering flame
glowSoft light blobs
dustBrown clouds that settle
explosionA fast burst
magicSparkles

effects.presets() lists them.

OptionRangeDescription
color, endColorcolour or "#rrggbb"Colour at birth and at death (fades to transparent by default)
size0.001–20Particle size in metres
lifetime0.02–30Seconds each particle lives
speed0–200Starting speed
spread0–180Cone angle in degrees (180 is every direction)
gravity-10–10Pull down (negative rises)
count0–2000Particles in a burst
rate0–500Particles per second for a running effect
additivebooleanGlowing (true) or solid (false) blending
texturepathA 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 world permission and type effects.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.