mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-27 00:17:32 +01:00
54 lines
903 B
Markdown
54 lines
903 B
Markdown
<!-- 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.
|
|
|
|
<b>Signature:</b>
|
|
|
|
```typescript
|
|
sleep(millis: number): Promise<void>;
|
|
```
|
|
|
|
## Parameters
|
|
|
|
| Parameter | Type | Description |
|
|
| --- | --- | --- |
|
|
| millis | number | Number of milliseconds to sleep. |
|
|
|
|
<b>Returns:</b>
|
|
|
|
Promise<void>
|
|
|
|
|
|
## Remarks
|
|
|
|
RAM cost: 0 GB
|
|
|
|
## 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);
|
|
}
|
|
```
|
|
|