Cancels the execution of a function run that was previously scheduled via System.run.
Function callback to run when the tickDelay time criteria is met.
An opaque identifier that can be used with the clearRun
function to cancel the execution of this run.
Runs a specified function at a future time. This is frequently used to implement delayed behaviors and game loops.
import { system, world } from '@minecraft/server';
function printEveryMinute() {
try {
// Minecraft runs at 20 ticks per second.
if (system.currentTick % 1200 === 0) {
world.sendMessage('Another minute passes...');
}
} catch (e) {
console.warn('Error: ' + e);
}
system.run(printEveryMinute);
}
printEveryMinute();
Functional code that will run when this interval occurs.
Optional
tickInterval: numberAn interval of every N ticks that the callback will be called upon.
An opaque handle that can be used with the clearRun method to stop the run of this function on an interval.
Functional code that will run when this timeout occurs.
Optional
tickDelay: numberAmount of time, in ticks, before the interval will be called.
An opaque handle that can be used with the clearRun method to stop the run of this function on an interval.
A class that provides system-level events and functions.