DOCUMENTATION: Fix wrong examples in NetscriptDefinitions.d.ts (#1295)

This commit is contained in:
catloversg 2024-05-23 15:42:47 +07:00 committed by GitHub
parent 81a707123e
commit 30c04f8152
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 26 additions and 26 deletions

@ -36,7 +36,7 @@ Attempts to solve the Coding Contract with the provided solution.
```js ```js
const reward = codingcontract.attempt(yourSolution, filename, hostname); const reward = ns.codingcontract.attempt(yourSolution, filename, hostname);
if (reward) { if (reward) {
ns.tprint(`Contract solved successfully! Reward: ${reward}`) ns.tprint(`Contract solved successfully! Reward: ${reward}`)
} else ns.tprint("Failed to solve contract.") } else ns.tprint("Failed to solve contract.")

@ -33,7 +33,7 @@ The amount of real time spent asleep between updates can vary due to "bonus time
```js ```js
while (true) { while (true) {
const prevState = await ns.corporation.nextUpdate(); const prevState = await ns.corporation.nextUpdate();
const nextState = ns.corporation.getCorporation().state; const nextState = ns.corporation.getCorporation().nextState;
ns.print(`Corporation finished with ${prevState}, next will be ${nextState}.`); ns.print(`Corporation finished with ${prevState}, next will be ${nextState}.`);
// Manage the Corporation // Manage the Corporation
} }

@ -28,7 +28,7 @@ Returns an object containing the Players hacking related multipliers. These m
```js ```js
const mults = ns.getHackingMultipliers(); const mults = ns.getHackingMultipliers();
print(`chance: ${mults.chance}`); ns.tprint(`chance: ${mults.chance}`);
print(`growth: ${mults.growth}`); ns.tprint(`growth: ${mults.growth}`);
``` ```

@ -36,6 +36,6 @@ Returns the cost to purchase a server with the specified amount of ram.
```js ```js
const ram = 2 ** 20; const ram = 2 ** 20;
const cost = ns.getPurchasedServerCost(ram); const cost = ns.getPurchasedServerCost(ram);
ns.tprint(`A purchased server with ${ns.formatRam(ram)} costs ${ns.formatMoney(cost)}`); ns.tprint(`A purchased server with ${ns.formatRam(ram)} costs $${ns.formatNumber(cost)}`);
``` ```

@ -28,8 +28,8 @@ The most recently killed script is the first element in the array. Note that the
```ts ```ts
let recentScripts = ns.getRecentScripts(); let recentScripts = ns.getRecentScripts();
let mostRecent = recentScripts.shift() let mostRecent = recentScripts.shift();
if (mostRecent) if (mostRecent)
ns.tprint(mostRecent.logs.join('\n')) ns.tprint(mostRecent.logs.join('\n'));
``` ```

@ -36,7 +36,7 @@ This function returns the decimal number of script threads you need when running
```ts ```ts
// Calculate threadcount of a single hack that would take $100k from n00dles // Calculate threadcount of a single hack that would take $100k from n00dles
const hackThreads = hackAnalyzeThreads("n00dles", 1e5); const hackThreads = ns.hackAnalyzeThreads("n00dles", 1e5);
// Launching a script requires an integer thread count. The below would take less than the targeted $100k. // Launching a script requires an integer thread count. The below would take less than the targeted $100k.
ns.run("noodleHack.js", Math.floor(hackThreads)) ns.run("noodleHack.js", Math.floor(hackThreads))

@ -40,7 +40,7 @@ Note that creating a program using this function has the same hacking level requ
```js ```js
const programName = "BruteSSH.exe"; const programName = "BruteSSH.exe";
const success = ns.createProgram(programName); const success = ns.singularity.createProgram(programName);
if (!success) ns.tprint("ERROR: Failed to start working on ${programName}") if (!success) ns.tprint("ERROR: Failed to start working on ${programName}")
``` ```

@ -37,7 +37,7 @@ If the program does not exist, an error is thrown.
```js ```js
const programName = "BruteSSH.exe"; const programName = "BruteSSH.exe";
const cost = ns.getDarkwebProgramCost(programName); const cost = ns.singularity.getDarkwebProgramCost(programName);
if (cost > 0) ns.tprint(`${programName} costs ${ns.formatMoney(cost)}`); if (cost > 0) ns.tprint(`${programName} costs $${ns.formatNumber(cost)}`);
``` ```

@ -27,7 +27,7 @@ This function allows the player to get a list of programs available for purchase
```js ```js
const programs = ns.getDarkwebPrograms(); const programs = ns.singularity.getDarkwebPrograms();
ns.tprint(`Available programs are: ${programs.split(", ")}`); ns.tprint(`Available programs are: ${programs.split(", ")}`);
``` ```

@ -35,7 +35,7 @@ This function allows you to automatically purchase programs. You MUST have a TOR
```js ```js
const programName = "BruteSSH.exe" const programName = "BruteSSH.exe"
const success = ns.purchaseProgram(programName); const success = ns.singularity.purchaseProgram(programName);
if (!success) ns.tprint("ERROR: Failed to purchase ${programName}") if (!success) ns.tprint("ERROR: Failed to purchase ${programName}")
``` ```

@ -1798,7 +1798,7 @@ export interface Singularity {
* @example * @example
* ```js * ```js
* const programName = "BruteSSH.exe" * const programName = "BruteSSH.exe"
* const success = ns.purchaseProgram(programName); * const success = ns.singularity.purchaseProgram(programName);
* if (!success) ns.tprint("ERROR: Failed to purchase ${programName}") * if (!success) ns.tprint("ERROR: Failed to purchase ${programName}")
* ``` * ```
* @param programName - Name of program to purchase. * @param programName - Name of program to purchase.
@ -2229,7 +2229,7 @@ export interface Singularity {
* @example * @example
* ```js * ```js
* const programName = "BruteSSH.exe"; * const programName = "BruteSSH.exe";
* const success = ns.createProgram(programName); * const success = ns.singularity.createProgram(programName);
* if (!success) ns.tprint("ERROR: Failed to start working on ${programName}") * if (!success) ns.tprint("ERROR: Failed to start working on ${programName}")
* ``` * ```
* @param program - Name of program to create. * @param program - Name of program to create.
@ -2536,7 +2536,7 @@ export interface Singularity {
* *
* @example * @example
* ```js * ```js
* const programs = ns.getDarkwebPrograms(); * const programs = ns.singularity.getDarkwebPrograms();
* ns.tprint(`Available programs are: ${programs.split(", ")}`); * ns.tprint(`Available programs are: ${programs.split(", ")}`);
* ``` * ```
* @returns - a list of programs available for purchase on the dark web, or [] if Tor has not * @returns - a list of programs available for purchase on the dark web, or [] if Tor has not
@ -2563,8 +2563,8 @@ export interface Singularity {
* @example * @example
* ```js * ```js
* const programName = "BruteSSH.exe"; * const programName = "BruteSSH.exe";
* const cost = ns.getDarkwebProgramCost(programName); * const cost = ns.singularity.getDarkwebProgramCost(programName);
* if (cost > 0) ns.tprint(`${programName} costs ${ns.formatMoney(cost)}`); * if (cost > 0) ns.tprint(`${programName} costs $${ns.formatNumber(cost)}`);
* ``` * ```
* @param programName - Name of program to check the price of * @param programName - Name of program to check the price of
* @returns Price of the specified darkweb program * @returns Price of the specified darkweb program
@ -3514,7 +3514,7 @@ export interface CodingContract {
* *
* @example * @example
* ```js * ```js
* const reward = codingcontract.attempt(yourSolution, filename, hostname); * const reward = ns.codingcontract.attempt(yourSolution, filename, hostname);
* if (reward) { * if (reward) {
* ns.tprint(`Contract solved successfully! Reward: ${reward}`) * ns.tprint(`Contract solved successfully! Reward: ${reward}`)
* } else ns.tprint("Failed to solve contract.") * } else ns.tprint("Failed to solve contract.")
@ -5525,7 +5525,7 @@ export interface NS {
* @example * @example
* ```ts * ```ts
* // Calculate threadcount of a single hack that would take $100k from n00dles * // Calculate threadcount of a single hack that would take $100k from n00dles
* const hackThreads = hackAnalyzeThreads("n00dles", 1e5); * const hackThreads = ns.hackAnalyzeThreads("n00dles", 1e5);
* *
* // Launching a script requires an integer thread count. The below would take less than the targeted $100k. * // Launching a script requires an integer thread count. The below would take less than the targeted $100k.
* ns.run("noodleHack.js", Math.floor(hackThreads)) * ns.run("noodleHack.js", Math.floor(hackThreads))
@ -5880,9 +5880,9 @@ export interface NS {
* @example * @example
* ```ts * ```ts
* let recentScripts = ns.getRecentScripts(); * let recentScripts = ns.getRecentScripts();
* let mostRecent = recentScripts.shift() * let mostRecent = recentScripts.shift();
* if (mostRecent) * if (mostRecent)
* ns.tprint(mostRecent.logs.join('\n')) * ns.tprint(mostRecent.logs.join('\n'));
* ``` * ```
* *
* @returns Array with information about previously killed scripts. * @returns Array with information about previously killed scripts.
@ -6396,8 +6396,8 @@ export interface NS {
* @example * @example
* ```js * ```js
* const mults = ns.getHackingMultipliers(); * const mults = ns.getHackingMultipliers();
* print(`chance: ${mults.chance}`); * ns.tprint(`chance: ${mults.chance}`);
* print(`growth: ${mults.growth}`); * ns.tprint(`growth: ${mults.growth}`);
* ``` * ```
* @returns Object containing the Players hacking related multipliers. * @returns Object containing the Players hacking related multipliers.
*/ */
@ -6644,7 +6644,7 @@ export interface NS {
* ```js * ```js
* const ram = 2 ** 20; * const ram = 2 ** 20;
* const cost = ns.getPurchasedServerCost(ram); * const cost = ns.getPurchasedServerCost(ram);
* ns.tprint(`A purchased server with ${ns.formatRam(ram)} costs ${ns.formatMoney(cost)}`); * ns.tprint(`A purchased server with ${ns.formatRam(ram)} costs $${ns.formatNumber(cost)}`);
* ``` * ```
* @param ram - Amount of RAM of a potential purchased server, in GB. Must be a power of 2 (2, 4, 8, 16, etc.). Maximum value of 1048576 (2^20). * @param ram - Amount of RAM of a potential purchased server, in GB. Must be a power of 2 (2, 4, 8, 16, etc.). Maximum value of 1048576 (2^20).
* @returns The cost to purchase a server with the specified amount of ram. * @returns The cost to purchase a server with the specified amount of ram.
@ -8211,7 +8211,7 @@ export interface Corporation extends WarehouseAPI, OfficeAPI {
* ```js * ```js
* while (true) { * while (true) {
* const prevState = await ns.corporation.nextUpdate(); * const prevState = await ns.corporation.nextUpdate();
* const nextState = ns.corporation.getCorporation().state; * const nextState = ns.corporation.getCorporation().nextState;
* ns.print(`Corporation finished with ${prevState}, next will be ${nextState}.`); * ns.print(`Corporation finished with ${prevState}, next will be ${nextState}.`);
* // Manage the Corporation * // Manage the Corporation
* } * }