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.
play_effect
Section titled “play_effect”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.
| Name | Type | What it is |
|---|---|---|
name | effect | Needed. |
options | table? | A table of the options below. It, and each option, may be left out. |
at | vector? | The point it bursts at, the origin without; with follow, an offset from where what it rides stands. |
dir | vector? | The way it points, up without. |
follow | (Player | Entity | number)? | A player or an entity it rides as it is drawn. |
loop | booleandefault false | Plays again each time it is over, until stop_effect, and play_effect gives the effect's entity. |
start | number-3600 to 5, default 0 | When 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. |
kind | string? | 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
To burst a grenade where it lands
Section titled “To burst a grenade where it lands”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)stop_effect
Section titled “stop_effect”stop_effect(effect)Stops a looping effect play_effect gave; one stopped already, or gone with what it rode, is left as it is.
| Name | Type | What it is |
|---|---|---|
effect | Entity | Needed. |
- 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)