mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-21 16:52:55 +02:00
48 lines
994 B
Markdown
48 lines
994 B
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
|
|
[Home](./index.md) > [bitburner](./bitburner.md) > [NS](./bitburner.ns.md) > [dynamicImport](./bitburner.ns.dynamicimport.md)
|
|
|
|
## NS.dynamicImport() method
|
|
|
|
Dynamically import a script. Only scripts located on the same server can be imported. A dynamic import will not adjust RAM usage. This must be done manually with [ramOverride](./bitburner.ns.ramoverride.md)<!-- -->.
|
|
|
|
**Signature:**
|
|
|
|
```typescript
|
|
dynamicImport(path: string): Promise<any>;
|
|
```
|
|
|
|
## Parameters
|
|
|
|
| Parameter | Type | Description |
|
|
| --- | --- | --- |
|
|
| path | string | |
|
|
|
|
**Returns:**
|
|
|
|
Promise<any>
|
|
|
|
## Remarks
|
|
|
|
RAM cost: 0 GB
|
|
|
|
## Example
|
|
|
|
File: script.js
|
|
|
|
```js
|
|
export async function main(ns){
|
|
const script = await ns.dynamicImport("./scriptToImport.js");
|
|
script.log(ns, "Message from an imported script!")
|
|
}
|
|
|
|
```
|
|
File: scriptToImport.js
|
|
|
|
```js
|
|
export async function log(ns, message){
|
|
ns.tprint(message);
|
|
}
|
|
```
|
|
|