Appearance
Random & delays
ctx.pick runs one of several bodies at random; ctx.wait and dp.after run a body later.
ts
ctx.pick([[3, (c) => c.say("common")], [1, (c) => c.say("rare")]]);| Call | Does |
|---|---|
ctx.pick([[w, body], ...]) | runs one body, chance proportional to w |
ctx.wait(time, body) | runs body later, as and at the same entity |
dp.after(ctx, time, body) | runs body later, as the server |
Delay per entity
Each entity waits on its own timer.
ts
ctx.wait(Time.seconds(2), (c) => c.particle(Particle.FLAME, Pos.here()));WARNING
Locals don't carry across a wait, and an entity that's gone by then never runs it.
See also
- Loops
- Math and
/compute: random values inside a formula