Task - Run Task Later (Section) — SkBee
Addon: SkBee · Category: Section · Since: 3.0.0
Syntax
[async] (run|execute) [task] %timespan% later [repeating every %-timespan%] [globally] [and store [task] id in %-object%]Description
Run a task later. Similar to Skript's delay effect, with the difference being everything in the section is run later. All code after your section will keep running as normal without a delay. This can be very useful in loops, to prevent halting the loop. You can optionally have your task repeat until cancelled. You can optionally run your code async/on another thread. You can optionally store the task ID in a variable, to help make use of it later.
**NOTE**: A good chunk of Bukkit/Minecraft stuff can NOT be run async. It may throw console errors. Please be careful when running async, this is generally reserved for heavy math/functions that could cause lag. Simply waiting a tick, or running a new non-async section will put your code back on the main thread.
**Patterns**: The 2nd pattern is only of concern if you are running Folia or have Paper schedulers enabled in the config, otherwise just use the first pattern. - `globally` = Will run this task on the global scheduler. - `for %entity` = Will run this task for an entity, will follow the entity around (region wise)and will cancel itself when the entity is no longer valid. - `at %location%` = Will run this task at a specific location (Use this for block changes in this section).
Examples
on explode: loop exploded blocks: set {_loc} to location of loop-block set {_data} to block data of loop-block run 2 seconds later: set block at {_loc} to {_data}
run 0 ticks later repeating every second and store id in {_id}: add 1 to {_a} if {_a} > 10: cancel task with id {_id}run 0 ticks later repeating every second: add 1 to {_a} if {_a} > 10: exit loop