runSubroutine

Schedules a subroutine feature to run. This is mostly useful for performing tasks after a certain amount of time has passed.

Signatures

beacon.runSubroutine(subroutineName);
beacon.runSubroutine(subroutineName, delay);
beacon.runSubroutine(subroutineName, delay, arguments);

Parameters

subroutineName

The name of the subroutine to run.

delay

Number of milliseconds (1 / 1000th of a second) to delay the start of the subroutine. The default value of 0 will start the subroutine immediately, likely before the current script has finished.

arguments

An object of argument values to pass into the subroutine. Since arguments have positional data, it is also possible to substitute plain values. See the example below.

Examples

Start and close a poll

beacon.sendChat('Should we run the swamp cave? Voting ends in 30 seconds.');
beacon.runSubroutine('Finish Poll', 30000);

Warn about dino wipe using positional arguments

beacon.runSubroutine('Delayed Chat Message', 0, 'Dino wipe coming in 5');
beacon.runSubroutine('Delayed Chat Message', 1000, 'Dino wipe coming in 4');
beacon.runSubroutine('Delayed Chat Message', 2000, 'Dino wipe coming in 3');
beacon.runSubroutine('Delayed Chat Message', 3000, 'Dino wipe coming in 2');
beacon.runSubroutine('Delayed Chat Message', 4000, 'Dino wipe coming in 1');
beacon.runSubroutine('Dino Wipe', 5000, 'Enjoy your few moments of peace');

Perfectly balanced, as all things should be

// Assumes an array of character objects has been selected.
// Loops over the array and performs a Snap Survivor routine,
// each on an increasing delay for dramatic effect. The
// subroutine could simply kill the survivor, or even ban
// them. The survivor is passed using an arguments object
// instead of positional arguments.
let delay = 0;
characters.forEach((character) => {
  beacon.runSubroutine('Snap Survivor', delay, {
    characterId: character.characterId,
  });
  delay = delay + 3000;
});