NETSCRIPT: Add the 'cat' method to 'ns.singularity' (#1999)

This commit is contained in:
Naga
2025-03-23 03:04:26 -04:00
committed by GitHub
parent 70a083b34b
commit 1539c428bc
5 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Singularity](./bitburner.singularity.md) &gt; [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

View File

@@ -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. |

View File

@@ -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),

View File

@@ -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<ISingularity> {
const runAfterReset = function (cbScript: ScriptFilePath) {
@@ -467,6 +468,12 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
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);

View File

@@ -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