Experimental

An early preview: docs, the API and the dashboard may change or break.

Report a problem
Module

@ember/effects

Particles, sounds and lightning. Nothing here changes the world or touches an entity.

local effects = require("@ember/effects")

Functions

effects.emitter(options: effects.EmitterOptions) -> effects.Emitter
#

Starts an emitter the host bursts on its own: no Lua per burst, and no packets while nobody is in range.

local effects = require("@ember/effects")
local players = require("@ember/players")
local types = require("@ember/types")
local world = require("@ember/world")

-- An emitter bursts on its own, with no script running per burst: cheaper than a particle loop.
-- This one marks the goal every half second for as long as the match runs.
effects.emitter({
	at = world.markers.single("goal").position,
	particles = { { id = "minecraft:end_rod", count = 4, spread = vector.create(0.3, 1, 0.3) } },
	every = 0.5,
})

-- Following a player, it stops by itself when they leave. Here each newcomer gets a 10-second
-- flame trail.
local function welcomeTrail(player: types.Player)
	effects.emitter({
		at = player,
		particles = { { id = "minecraft:flame", offset = vector.create(0, 2.2, 0) } },
		every = 0.1,
		duration = 10,
	})
end

players.joined:connect(welcomeTrail)
effects.lightning(at: vector)
#

A bolt with its flash and thunder that harms nothing and sets no fire; it fades after a second.

local effects = require("@ember/effects")
local players = require("@ember/players")

-- Lightning is only a show: it hurts nobody and lights no fires. Strike where a player fell.
players.joined:connect(function(player)
	player.died:connect(function()
		effects.lightning(player.position)
	end)
end)
effects.particle(particle: effects.Particle, at: vector, to: effects.Audience?)
#

Shows a particle at at to to, or to everyone in the world.

local effects = require("@ember/effects")
local world = require("@ember/world")

-- A one-off burst. `spread` scatters the particles around the point on each axis.
world.broken:connect(function(event)
	effects.particle({
		id = "minecraft:happy_villager",
		count = 12,
		spread = vector.create(0.4, 0.4, 0.4),
	}, event.position + vector.create(0.5, 0.5, 0.5))
end)

-- `dust` takes a colour as 0xRRGGBB.
world.placed:connect(function(event)
	effects.particle({ id = "minecraft:dust", color = 0xFF5555, count = 6 }, event.position + vector.create(0.5, 1.1, 0.5), event.player)
end)
effects.sound(id: string, options: effects.SoundOptions?)
#

Plays a sound; id is a minecraft: sound event.

local effects = require("@ember/effects")
local players = require("@ember/players")
local world = require("@ember/world")

-- With `at`, a sound comes from a place and fades with distance; without it, each listener hears
-- it at themselves, like a UI sound.
world.broken:connect(function(event)
	effects.sound("minecraft:entity.experience_orb.pickup", { at = event.position, pitch = 1.5 })
end)

-- Only the player who joined hears this one.
players.joined:connect(function(player)
	effects.sound("minecraft:ui.toast.challenge_complete", { to = player, volume = 0.6 })
end)

Types