change asleep

This commit is contained in:
Olivier Gagnon 2022-01-18 18:57:43 -05:00
parent 05cbc25a8f
commit d0a44a6088
2 changed files with 3 additions and 5 deletions

@ -577,9 +577,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
throw makeRuntimeErrorMsg("asleep", "Takes 1 argument.");
}
workerScript.log("asleep", () => `Sleeping for ${time} milliseconds`);
return netscriptDelay(time, workerScript).then(function () {
return Promise.resolve(true);
});
return new Promise((resolve) => setTimeout(resolve, time));
},
grow: function (hostname: any, { threads: requestedThreads, stock }: any = {}): any {
updateDynamicRam("grow", getRamCost(Player, "grow"));

@ -178,7 +178,7 @@ function startNetscript1Script(workerScript: WorkerScript): Promise<WorkerScript
const entry = ns[name];
if (typeof entry === "function") {
//Async functions need to be wrapped. See JS-Interpreter documentation
if (["hack", "grow", "weaken", "sleep", "prompt", "manualHack", "scp", "write"].includes(name)) {
if (["hack", "grow", "weaken", "sleep", "prompt", "manualHack", "scp", "write", "share"].includes(name)) {
const tempWrapper = function (...args: any[]): void {
const fnArgs = [];