Skip to content

Effects

Particle effects, such as an explosion or smoke: .effect files the mod plays at a point, along a direction, or riding something that moves. An effect played once ends by itself; one that loops is an entity until it is stopped.

Like sounds, effects start at the moment the server says, so an explosion shows as the grenade lands, however late a player’s game hears of it.

On the server play_effect(name, options?) → Entity?

Sets off a particle effect for the players who see it, once, or again and again with loop until stop_effect.

An effect played once ends by itself; with loop, play_effect gives the effect’s entity, which kind names, so kind without loop fails. One that rides something absent is not set off. Once what it rides goes, a burst stays where it was last; a loop goes with it.

NameTypeWhat it is
nameeffectNeeded.
optionstable?A table of the options below. It, and each option, may be left out.
atvector?The point it bursts at, the origin without; with follow, an offset from where what it rides stands.
dirvector?The way it points, up without.
follow(Player | Entity | number)?A player or an entity it rides as it is drawn.
loopbooleandefault falsePlays again each time it is over, until stop_effect, and play_effect gives the effect's entity.
startnumber-3600 to 5, default 0When it starts, in seconds from now: up to an hour ago, seen from part-way through, or up to 5 s ahead.
owner(Player | number)?The player it is about, whom owner, team and spectators pick by.
read_by(Group | ((Player?, Player) -> boolean))?Who is shown it; everyone without.
kindstring?Its kind, one entity_kind declared on its base; the base's own without.
Returns
Entity?
Fails
  • a value of the wrong type
  • an option it does not have
  • a value outside its range
play_effect("explosion", { at = p.position })

To puff smoke from a wall, pointing away from it

Section titled “To puff smoke from a wall, pointing away from it”
play_effect("smoke", { at = vector.create(0, 1, 4), dir = vector.create(0, 0, -1) })

To keep a zombie smoking as it walks, and stop it

Section titled “To keep a zombie smoking as it walks, and stop it”
local zombie = spawn()
local smoke = play_effect("smoke", { follow = zombie, at = vector.create(0, 1.6, 0), loop = true })
wait(5)
stop_effect(smoke)
On the server stop_effect(effect)

Stops a looping effect play_effect gave; one stopped already, or gone with what it rode, is left as it is.

NameTypeWhat it is
effectEntityNeeded.
Fails
  • a value of the wrong type

To stop a fire once it has burned for ten seconds

Section titled “To stop a fire once it has burned for ten seconds”
local fire = play_effect("smoke", { at = vector.create(2, 0, 2), loop = true })
wait(10)
stop_effect(fire)