SLEEVE: Add sleeve.setToIdle function (#374)

This commit is contained in:
Zelow79 2023-02-19 00:13:23 -05:00 committed by GitHub
parent bd4fe19fde
commit 028199aa7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

@ -289,6 +289,7 @@ const codingcontract = {
// Duplicate Sleeve API // Duplicate Sleeve API
const sleeve = { const sleeve = {
getNumSleeves: RamCostConstants.SleeveBase, getNumSleeves: RamCostConstants.SleeveBase,
setToIdle: RamCostConstants.SleeveBase,
setToShockRecovery: RamCostConstants.SleeveBase, setToShockRecovery: RamCostConstants.SleeveBase,
setToSynchronize: RamCostConstants.SleeveBase, setToSynchronize: RamCostConstants.SleeveBase,
setToCommitCrime: RamCostConstants.SleeveBase, setToCommitCrime: RamCostConstants.SleeveBase,

@ -36,6 +36,12 @@ export function NetscriptSleeve(): InternalAPI<Sleeve> {
checkSleeveAPIAccess(ctx); checkSleeveAPIAccess(ctx);
return Player.sleeves.length; 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) => { setToShockRecovery: (ctx) => (_sleeveNumber) => {
const sleeveNumber = helpers.number(ctx, "sleeveNumber", _sleeveNumber); const sleeveNumber = helpers.number(ctx, "sleeveNumber", _sleeveNumber);
checkSleeveAPIAccess(ctx); checkSleeveAPIAccess(ctx);

@ -3587,6 +3587,15 @@ export interface Sleeve {
*/ */
getTask(sleeveNumber: number): SleeveTask | null; 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. * Set a sleeve to shock recovery.
* @remarks * @remarks