mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-25 02:32:55 +02:00
NETSCRIPT: A minorly breaking change around script launch, and refactoring. (#1213)
This commit is contained in:
@@ -57,10 +57,12 @@ async function startNetscript2Script(workerScript: WorkerScript): Promise<void>
|
||||
const loadedModule = await compile(script, scripts);
|
||||
|
||||
if (!loadedModule) throw `${script.filename} cannot be run because the script module won't load`;
|
||||
const mainFunc = loadedModule.main;
|
||||
// TODO unplanned: Better error for "unexpected reserved word" when using await in non-async function?
|
||||
if (typeof loadedModule.main !== "function")
|
||||
if (typeof mainFunc !== "function")
|
||||
throw `${script.filename} cannot be run because it does not have a main function.`;
|
||||
await loadedModule.main(ns);
|
||||
// Explicitly called from a variable so that we don't bind "this".
|
||||
await mainFunc(ns);
|
||||
}
|
||||
|
||||
async function startNetscript1Script(workerScript: WorkerScript): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user