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."); throw makeRuntimeErrorMsg("asleep", "Takes 1 argument.");
} }
workerScript.log("asleep", () => `Sleeping for ${time} milliseconds`); workerScript.log("asleep", () => `Sleeping for ${time} milliseconds`);
return netscriptDelay(time, workerScript).then(function () { return new Promise((resolve) => setTimeout(resolve, time));
return Promise.resolve(true);
});
}, },
grow: function (hostname: any, { threads: requestedThreads, stock }: any = {}): any { grow: function (hostname: any, { threads: requestedThreads, stock }: any = {}): any {
updateDynamicRam("grow", getRamCost(Player, "grow")); updateDynamicRam("grow", getRamCost(Player, "grow"));
@ -715,7 +713,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
end(); end();
}); });
}, },
getSharePower: function(): number { getSharePower: function (): number {
return CalculateShareMult(); return CalculateShareMult();
}, },
print: function (...args: any[]): void { print: function (...args: any[]): void {

@ -178,7 +178,7 @@ function startNetscript1Script(workerScript: WorkerScript): Promise<WorkerScript
const entry = ns[name]; const entry = ns[name];
if (typeof entry === "function") { if (typeof entry === "function") {
//Async functions need to be wrapped. See JS-Interpreter documentation //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 tempWrapper = function (...args: any[]): void {
const fnArgs = []; const fnArgs = [];