fix undying script bug

This commit is contained in:
Olivier Gagnon 2021-12-14 19:39:55 -05:00
parent 4d80813707
commit 5b38ee3cfb
6 changed files with 17 additions and 10 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -941,6 +941,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
return runScriptFromScript("run", scriptServer, scriptname, args, workerScript, threads);
},
exec: function (scriptname: any, hostname: any, threads: any = 1, ...args: any[]): any {
console.log(`${scriptname} ${hostname} ${threads} ${JSON.stringify(args)}`);
updateDynamicRam("exec", getRamCost("exec"));
if (scriptname === undefined || hostname === undefined) {
throw makeRuntimeErrorMsg("exec", "Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)");
@ -1061,11 +1062,13 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
throw makeRuntimeErrorMsg("scp", "No scripts to copy");
}
let res = true;
await Promise.all(scripts.map(async function(script) {
if (!await NetscriptFunctions(workerScript).scp(script, hostname1, hostname2)) {
res = false;
}
}));
await Promise.all(
scripts.map(async function (script) {
if (!(await NetscriptFunctions(workerScript).scp(script, hostname1, hostname2))) {
res = false;
}
}),
);
return Promise.resolve(res);
}

@ -709,6 +709,7 @@ export function runScriptFromScript(
);
const runningScriptObj = new RunningScript(script, args);
runningScriptObj.threads = threads;
runningScriptObj.server = server.hostname;
return startWorkerScript(runningScriptObj, server, workerScript);
}

@ -443,8 +443,11 @@ export function InteractiveTutorialRoot(): React.ReactElement {
<Typography color={"primary"}>Tutorial</Typography>
</ListItem>
<Typography>
in the main navigation menu to look at the documentation. If you are an experienced JavaScript developer, I
would highly suggest you check out the section on NetscriptJS/Netscript 2.0, it's faster and more powerful.
in the main navigation menu to look at the documentation.
<br />
<br />
If you know even a little bit of programming it is highly recommended you use NS2 instead. You will enjoy
the game much more.
<br />
<br />
For now, let's move on to something else!