mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 09:43:54 +01:00
sleep/asleep return promise true
This commit is contained in:
parent
e07a223d77
commit
724c0669da
@ -601,7 +601,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
|
|
||||||
return calculateHackingChance(server, Player);
|
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);
|
const time = helper.number("sleep", "time", _time);
|
||||||
updateDynamicRam("sleep", getRamCost(Player, "sleep"));
|
updateDynamicRam("sleep", getRamCost(Player, "sleep"));
|
||||||
if (time === undefined) {
|
if (time === undefined) {
|
||||||
@ -609,17 +609,17 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}
|
}
|
||||||
workerScript.log("sleep", () => `Sleeping for ${time} milliseconds`);
|
workerScript.log("sleep", () => `Sleeping for ${time} milliseconds`);
|
||||||
return netscriptDelay(time, workerScript).then(function () {
|
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);
|
const time = helper.number("asleep", "time", _time);
|
||||||
updateDynamicRam("asleep", getRamCost(Player, "asleep"));
|
updateDynamicRam("asleep", getRamCost(Player, "asleep"));
|
||||||
if (time === undefined) {
|
if (time === undefined) {
|
||||||
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 new Promise((resolve) => setTimeout(resolve, time));
|
return new Promise((resolve) => setTimeout(() => resolve(true), time));
|
||||||
},
|
},
|
||||||
grow: async function (
|
grow: async function (
|
||||||
_hostname: unknown,
|
_hostname: unknown,
|
||||||
|
4
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
4
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -4642,7 +4642,7 @@ export interface NS extends Singularity {
|
|||||||
* ```
|
* ```
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
sleep(millis: number): Promise<void>;
|
sleep(millis: number): Promise<true>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Suspends the script for n milliseconds. Doesn't block with concurrent calls.
|
* 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.
|
* @param millis - Number of milliseconds to sleep.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
asleep(millis: number): Promise<void>;
|
asleep(millis: number): Promise<true>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints one or move values or variables to the script’s logs.
|
* Prints one or move values or variables to the script’s logs.
|
||||||
|
Loading…
Reference in New Issue
Block a user