Merge pull request #1423 from danielyxie/dev

fix netscript port read not correctly converting ns1 objects
This commit is contained in:
hydroflame 2021-10-05 16:38:16 -04:00 committed by GitHub
commit 3a0b3612bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -2396,7 +2396,9 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
if (iport == null || !(iport instanceof Object)) {
throw makeRuntimeErrorMsg("read", `Could not find port: ${port}. This is a bug. Report to dev.`);
}
return iport.read();
const x = iport.read();
console.log(x);
return x;
} else if (isString(port)) {
// Read from script or text file
const fn = port;
@ -2443,7 +2445,9 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
if (iport == null || !(iport instanceof Object)) {
throw makeRuntimeErrorMsg("peek", `Could not find port: ${port}. This is a bug. Report to dev.`);
}
return iport.peek();
const x = iport.peek();
console.log(x);
return x;
},
clear: function (port: any): any {
updateDynamicRam("clear", getRamCost("clear"));

@ -198,7 +198,6 @@ function startNetscript1Script(workerScript: WorkerScript): Promise<WorkerScript
name === "vsprintf" ||
name === "scp" ||
name == "write" ||
name === "read" ||
name === "tryWrite" ||
name === "run" ||
name === "exec"