2022-10-21 17:16:00 +02:00
|
|
|
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
|
|
|
|
|
|
[Home](./index.md) > [bitburner](./bitburner.md) > [NS](./bitburner.ns.md) > [sleep](./bitburner.ns.sleep.md)
|
|
|
|
|
|
|
|
## NS.sleep() method
|
|
|
|
|
|
|
|
Suspends the script for n milliseconds.
|
|
|
|
|
2023-02-11 19:18:50 +01:00
|
|
|
**Signature:**
|
2022-10-21 17:16:00 +02:00
|
|
|
|
|
|
|
```typescript
|
|
|
|
sleep(millis: number): Promise<true>;
|
|
|
|
```
|
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
|
|
|
| Parameter | Type | Description |
|
|
|
|
| --- | --- | --- |
|
|
|
|
| millis | number | Number of milliseconds to sleep. |
|
|
|
|
|
2023-02-11 19:18:50 +01:00
|
|
|
**Returns:**
|
2022-10-21 17:16:00 +02:00
|
|
|
|
|
|
|
Promise<true>
|
|
|
|
|
2023-04-28 20:19:30 +02:00
|
|
|
A promise that resolves to true when the sleep is completed.
|
2022-10-21 17:16:00 +02:00
|
|
|
|
|
|
|
## Remarks
|
|
|
|
|
|
|
|
RAM cost: 0 GB
|
|
|
|
|
2023-04-28 20:19:30 +02:00
|
|
|
## Example
|
2022-10-21 17:16:00 +02:00
|
|
|
|
|
|
|
|
2023-04-28 20:19:30 +02:00
|
|
|
```js
|
2022-10-21 17:16:00 +02:00
|
|
|
// This will count from 1 to 10 in your terminal, with one number every 5 seconds
|
2023-04-28 20:19:30 +02:00
|
|
|
for (var i = 1; i <= 10; i++) {
|
|
|
|
ns.tprint(i);
|
2022-10-21 17:16:00 +02:00
|
|
|
await ns.sleep(5000);
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|