Add some more utility functions
This commit is contained in:
parent
01ea52d4d7
commit
50117674e1
@ -1,5 +1,10 @@
|
|||||||
// noinspection JSUnusedGlobalSymbols
|
// noinspection JSUnusedGlobalSymbols
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file Utility functions for Bitburner
|
||||||
|
* @note Some functions are currently untested
|
||||||
|
*/
|
||||||
|
|
||||||
import {NS} from "NetscriptDefinitions";
|
import {NS} from "NetscriptDefinitions";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,3 +114,20 @@ export function performFunctionIfCapable(ns: NS, server: string, func: CallableF
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes a script on a server from another server
|
||||||
|
* @param ns Global NS object
|
||||||
|
* @param script The file path of the script to execute
|
||||||
|
* @param args The arguments to pass to the script
|
||||||
|
* @param server The server to execute the script on
|
||||||
|
*/
|
||||||
|
export function executeScriptOnServerFromAnother(ns: NS, script: string, args: any[], server: string) {
|
||||||
|
ns.scp(script, server);
|
||||||
|
performFunctionIfCapable(ns, server, ns.exec, [script, server, ...args])
|
||||||
|
ns.atExit(
|
||||||
|
() => {
|
||||||
|
ns.rm(script, server);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user