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.