bitburner-src/markdown/bitburner.ns.sleep.md

54 lines
903 B
Markdown
Raw Normal View History

2021-10-30 18:34:14 +02:00
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NS](./bitburner.ns.md) &gt; [sleep](./bitburner.ns.sleep.md)
## NS.sleep() method
Suspends the script for n milliseconds.
<b>Signature:</b>
```typescript
2022-04-13 07:35:35 +02:00
sleep(millis: number): Promise<true>;
2021-10-30 18:34:14 +02:00
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| millis | number | Number of milliseconds to sleep. |
<b>Returns:</b>
2022-04-13 07:35:35 +02:00
Promise&lt;true&gt;
2021-10-30 18:34:14 +02:00
## Remarks
2021-10-30 21:46:34 +02:00
RAM cost: 0 GB
2021-10-30 18:34:14 +02:00
2022-01-08 19:25:06 +01:00
## Example 1
```ts
// 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
```ts
// 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);
}
```