From 1539c428bc6f1eff98522fd687e67c099194a9f3 Mon Sep 17 00:00:00 2001 From: Naga <92240446+NagaOuroboros@users.noreply.github.com> Date: Sun, 23 Mar 2025 03:04:26 -0400 Subject: [PATCH] NETSCRIPT: Add the 'cat' method to 'ns.singularity' (#1999) --- markdown/bitburner.singularity.cat.md | 28 ++++++++++++++++++++++ markdown/bitburner.singularity.md | 1 + src/Netscript/RamCostGenerator.ts | 1 + src/NetscriptFunctions/Singularity.ts | 7 ++++++ src/ScriptEditor/NetscriptDefinitions.d.ts | 9 +++++++ 5 files changed, 46 insertions(+) create mode 100644 markdown/bitburner.singularity.cat.md diff --git a/markdown/bitburner.singularity.cat.md b/markdown/bitburner.singularity.cat.md new file mode 100644 index 000000000..bcd4dd639 --- /dev/null +++ b/markdown/bitburner.singularity.cat.md @@ -0,0 +1,28 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [Singularity](./bitburner.singularity.md) > [cat](./bitburner.singularity.cat.md) + +## Singularity.cat() method + +Displays the content of a file on the currently connected server. + +**Signature:** + +```typescript +cat(filename: string): void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| filename | string | Name of the file to display, including its extension. | + +**Returns:** + +void + +## Remarks + +RAM cost: 0.5 \* 16/4/1 + diff --git a/markdown/bitburner.singularity.md b/markdown/bitburner.singularity.md index ad4965ebc..f924d2dd9 100644 --- a/markdown/bitburner.singularity.md +++ b/markdown/bitburner.singularity.md @@ -22,6 +22,7 @@ This API requires Source-File 4 to use. The RAM cost of all these functions is m | --- | --- | | [applyToCompany(companyName, field)](./bitburner.singularity.applytocompany.md) | Apply for a job at a company. | | [b1tflum3(nextBN, callbackScript, bitNodeOptions)](./bitburner.singularity.b1tflum3.md) | b1t\_flum3 into a different BN. | +| [cat(filename)](./bitburner.singularity.cat.md) | Displays the content of a file on the currently connected server. | | [checkFactionInvitations()](./bitburner.singularity.checkfactioninvitations.md) | List all current faction invitations. | | [commitCrime(crime, focus)](./bitburner.singularity.commitcrime.md) | Commit a crime. | | [connect(hostname)](./bitburner.singularity.connect.md) | Connect to a server. | diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts index 524980668..711dfacc2 100644 --- a/src/Netscript/RamCostGenerator.ts +++ b/src/Netscript/RamCostGenerator.ts @@ -169,6 +169,7 @@ const singularity = { getCurrentServer: SF4Cost(RamCostConstants.SingularityFn1), getCompanyPositionInfo: SF4Cost(RamCostConstants.SingularityFn1), getCompanyPositions: SF4Cost(RamCostConstants.SingularityFn1), + cat: SF4Cost(RamCostConstants.SingularityFn1 / 4), connect: SF4Cost(RamCostConstants.SingularityFn1), manualHack: SF4Cost(RamCostConstants.SingularityFn1), installBackdoor: SF4Cost(RamCostConstants.SingularityFn1), diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index c4764488f..52429e7a8 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -52,6 +52,7 @@ import { calculateEffectiveRequiredReputation } from "../Company/utils"; import { calculateFavorAfterResetting } from "../Faction/formulas/favor"; import { validBitNodes } from "../BitNode/BitNodeUtils"; import { exceptionAlert } from "../utils/helpers/exceptionAlert"; +import { cat } from "../Terminal/commands/cat"; export function NetscriptSingularity(): InternalAPI { const runAfterReset = function (cbScript: ScriptFilePath) { @@ -467,6 +468,12 @@ export function NetscriptSingularity(): InternalAPI { helpers.checkSingularityAccess(ctx); return Player.getCurrentServer().hostname; }, + cat: (ctx) => (_filename) => { + helpers.checkSingularityAccess(ctx); + const filename = helpers.string(ctx, "filename", _filename); + const server = Player.getCurrentServer(); + cat([filename], server); + }, connect: (ctx) => (_hostname) => { helpers.checkSingularityAccess(ctx); const hostname = helpers.string(ctx, "hostname", _hostname); diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 690003d74..d3a377881 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -2656,6 +2656,15 @@ export interface Singularity { */ getCurrentServer(): string; + /** + * Displays the content of a file on the currently connected server. + * @remarks + * RAM cost: 0.5 * 16/4/1 + * + * @param filename - Name of the file to display, including its extension. + */ + cat(filename: string): void; + /** * Connect to a server. * @remarks