From 028199aa7d30e0f5e7366f6645f9f398565862e2 Mon Sep 17 00:00:00 2001 From: Zelow79 <32428876+Zelow79@users.noreply.github.com> Date: Sun, 19 Feb 2023 00:13:23 -0500 Subject: [PATCH] SLEEVE: Add sleeve.setToIdle function (#374) --- src/Netscript/RamCostGenerator.ts | 1 + src/NetscriptFunctions/Sleeve.ts | 6 ++++++ src/ScriptEditor/NetscriptDefinitions.d.ts | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts index 782fd880e..6269bf0ad 100644 --- a/src/Netscript/RamCostGenerator.ts +++ b/src/Netscript/RamCostGenerator.ts @@ -289,6 +289,7 @@ const codingcontract = { // Duplicate Sleeve API const sleeve = { getNumSleeves: RamCostConstants.SleeveBase, + setToIdle: RamCostConstants.SleeveBase, setToShockRecovery: RamCostConstants.SleeveBase, setToSynchronize: RamCostConstants.SleeveBase, setToCommitCrime: RamCostConstants.SleeveBase, diff --git a/src/NetscriptFunctions/Sleeve.ts b/src/NetscriptFunctions/Sleeve.ts index a893d2f0b..63770ec23 100644 --- a/src/NetscriptFunctions/Sleeve.ts +++ b/src/NetscriptFunctions/Sleeve.ts @@ -36,6 +36,12 @@ export function NetscriptSleeve(): InternalAPI { checkSleeveAPIAccess(ctx); return Player.sleeves.length; }, + setToIdle: (ctx) => (_sleeveNumber) => { + const sleeveNumber = helpers.number(ctx, "sleeveNumber", _sleeveNumber); + checkSleeveAPIAccess(ctx); + checkSleeveNumber(ctx, sleeveNumber); + Player.sleeves[sleeveNumber].stopWork(); + }, setToShockRecovery: (ctx) => (_sleeveNumber) => { const sleeveNumber = helpers.number(ctx, "sleeveNumber", _sleeveNumber); checkSleeveAPIAccess(ctx); diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index a87541a4f..117ff56f4 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -3587,6 +3587,15 @@ export interface Sleeve { */ getTask(sleeveNumber: number): SleeveTask | null; + /** + * Set a sleeve to idle. + * @remarks + * RAM cost: 4 GB + * + * @param sleeveNumber - Index of the sleeve to idle. + */ + setToIdle(sleeveNumber: number): void; + /** * Set a sleeve to shock recovery. * @remarks