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