sleep/asleep return promise true

This commit is contained in:
Olivier Gagnon 2022-04-06 19:38:30 -04:00
parent e07a223d77
commit 724c0669da
2 changed files with 6 additions and 6 deletions

@ -601,7 +601,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
return calculateHackingChance(server, Player);
},
sleep: async function (_time: unknown = 0): Promise<void> {
sleep: async function (_time: unknown = 0): Promise<true> {
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<void> {
asleep: function (_time: unknown = 0): Promise<true> {
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,

@ -4642,7 +4642,7 @@ export interface NS extends Singularity {
* ```
* @returns
*/
sleep(millis: number): Promise<void>;
sleep(millis: number): Promise<true>;
/**
* 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<void>;
asleep(millis: number): Promise<true>;
/**
* Prints one or move values or variables to the scripts logs.