bitburner-src/markdown/bitburner.ns.sleep.md
omuretsu 06a985bdf8 Revert "Remove markdown from git tracking (#139)"
This reverts commit bbb6e3f309935aebac74ddb1fbeec12dfb7540b1.
2022-10-21 11:16:00 -04:00

903 B

Home > bitburner > NS > sleep

NS.sleep() method

Suspends the script for n milliseconds.

Signature:

sleep(millis: number): Promise<true>;

Parameters

Parameter Type Description
millis number Number of milliseconds to sleep.

Returns:

Promise<true>

Remarks

RAM cost: 0 GB

Example 1

// NS1:
// This will count from 1 to 10 in your terminal, with one number every 5 seconds
for (var i=0; i<10; i++) {
  tprint(i + 1);
  sleep(5000);
}

Example 2

// NS2:
// This will count from 1 to 10 in your terminal, with one number every 5 seconds
for (var i=0; i<10; i++) {
  ns.tprint(i + 1);
  await ns.sleep(5000);
}