From 724c0669da6f450f705acb43cb02d7a4b39c9032 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Wed, 6 Apr 2022 19:38:30 -0400 Subject: [PATCH] sleep/asleep return promise true --- src/NetscriptFunctions.ts | 8 ++++---- src/ScriptEditor/NetscriptDefinitions.d.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 113d3267a..d20046895 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -601,7 +601,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { return calculateHackingChance(server, Player); }, - sleep: async function (_time: unknown = 0): Promise { + sleep: async function (_time: unknown = 0): Promise { const time = helper.number("sleep", "time", _time); updateDynamicRam("sleep", getRamCost(Player, "sleep")); if (time === undefined) { @@ -609,17 +609,17 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { } workerScript.log("sleep", () => `Sleeping for ${time} milliseconds`); return netscriptDelay(time, workerScript).then(function () { - return Promise.resolve(); + return Promise.resolve(true); }); }, - asleep: function (_time: unknown = 0): Promise { + asleep: function (_time: unknown = 0): Promise { const time = helper.number("asleep", "time", _time); updateDynamicRam("asleep", getRamCost(Player, "asleep")); if (time === undefined) { throw makeRuntimeErrorMsg("asleep", "Takes 1 argument."); } workerScript.log("asleep", () => `Sleeping for ${time} milliseconds`); - return new Promise((resolve) => setTimeout(resolve, time)); + return new Promise((resolve) => setTimeout(() => resolve(true), time)); }, grow: async function ( _hostname: unknown, diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index fde653d5d..4c49b15e1 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -4642,7 +4642,7 @@ export interface NS extends Singularity { * ``` * @returns */ - sleep(millis: number): Promise; + sleep(millis: number): Promise; /** * Suspends the script for n milliseconds. Doesn't block with concurrent calls. @@ -4652,7 +4652,7 @@ export interface NS extends Singularity { * @param millis - Number of milliseconds to sleep. * @returns */ - asleep(millis: number): Promise; + asleep(millis: number): Promise; /** * Prints one or move values or variables to the script’s logs.