mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 14:28:36 +02:00
API: dynamic imports with ns.dynamicImport() (#2036)
This commit is contained in:
28
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
28
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@@ -8370,6 +8370,34 @@ export interface NS {
|
||||
*/
|
||||
getSharePower(): number;
|
||||
|
||||
/**
|
||||
* 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 {@link NS.ramOverride|ramOverride}.
|
||||
*
|
||||
* @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);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @remarks
|
||||
* RAM cost: 0 GB
|
||||
*/
|
||||
dynamicImport(path: string): Promise<any>;
|
||||
|
||||
enums: NSEnums;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user