From 30c04f81520354c373e6d5e42f3d8cfe44d1764e Mon Sep 17 00:00:00 2001 From: catloversg <152669316+catloversg@users.noreply.github.com> Date: Thu, 23 May 2024 15:42:47 +0700 Subject: [PATCH] DOCUMENTATION: Fix wrong examples in NetscriptDefinitions.d.ts (#1295) --- markdown/bitburner.codingcontract.attempt.md | 2 +- markdown/bitburner.corporation.nextupdate.md | 2 +- .../bitburner.ns.gethackingmultipliers.md | 4 +-- .../bitburner.ns.getpurchasedservercost.md | 2 +- markdown/bitburner.ns.getrecentscripts.md | 4 +-- markdown/bitburner.ns.hackanalyzethreads.md | 2 +- .../bitburner.singularity.createprogram.md | 2 +- ...urner.singularity.getdarkwebprogramcost.md | 4 +-- ...itburner.singularity.getdarkwebprograms.md | 2 +- .../bitburner.singularity.purchaseprogram.md | 2 +- src/ScriptEditor/NetscriptDefinitions.d.ts | 26 +++++++++---------- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/markdown/bitburner.codingcontract.attempt.md b/markdown/bitburner.codingcontract.attempt.md index 437db8130..68c7e1308 100644 --- a/markdown/bitburner.codingcontract.attempt.md +++ b/markdown/bitburner.codingcontract.attempt.md @@ -36,7 +36,7 @@ Attempts to solve the Coding Contract with the provided solution. ```js -const reward = codingcontract.attempt(yourSolution, filename, hostname); +const reward = ns.codingcontract.attempt(yourSolution, filename, hostname); if (reward) { ns.tprint(`Contract solved successfully! Reward: ${reward}`) } else ns.tprint("Failed to solve contract.") diff --git a/markdown/bitburner.corporation.nextupdate.md b/markdown/bitburner.corporation.nextupdate.md index 2f05955f1..3057212a3 100644 --- a/markdown/bitburner.corporation.nextupdate.md +++ b/markdown/bitburner.corporation.nextupdate.md @@ -33,7 +33,7 @@ The amount of real time spent asleep between updates can vary due to "bonus time ```js while (true) { 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}.`); // Manage the Corporation } diff --git a/markdown/bitburner.ns.gethackingmultipliers.md b/markdown/bitburner.ns.gethackingmultipliers.md index c2c88f490..38ed394e8 100644 --- a/markdown/bitburner.ns.gethackingmultipliers.md +++ b/markdown/bitburner.ns.gethackingmultipliers.md @@ -28,7 +28,7 @@ Returns an object containing the Player’s hacking related multipliers. These m ```js const mults = ns.getHackingMultipliers(); -print(`chance: ${mults.chance}`); -print(`growth: ${mults.growth}`); +ns.tprint(`chance: ${mults.chance}`); +ns.tprint(`growth: ${mults.growth}`); ``` diff --git a/markdown/bitburner.ns.getpurchasedservercost.md b/markdown/bitburner.ns.getpurchasedservercost.md index 8ffc5b43e..f2e44bf8e 100644 --- a/markdown/bitburner.ns.getpurchasedservercost.md +++ b/markdown/bitburner.ns.getpurchasedservercost.md @@ -36,6 +36,6 @@ Returns the cost to purchase a server with the specified amount of ram. ```js const ram = 2 ** 20; 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)}`); ``` diff --git a/markdown/bitburner.ns.getrecentscripts.md b/markdown/bitburner.ns.getrecentscripts.md index 4caf196f1..a2e5030bd 100644 --- a/markdown/bitburner.ns.getrecentscripts.md +++ b/markdown/bitburner.ns.getrecentscripts.md @@ -28,8 +28,8 @@ The most recently killed script is the first element in the array. Note that the ```ts let recentScripts = ns.getRecentScripts(); -let mostRecent = recentScripts.shift() +let mostRecent = recentScripts.shift(); if (mostRecent) - ns.tprint(mostRecent.logs.join('\n')) + ns.tprint(mostRecent.logs.join('\n')); ``` diff --git a/markdown/bitburner.ns.hackanalyzethreads.md b/markdown/bitburner.ns.hackanalyzethreads.md index b2aed6a78..e95f783e5 100644 --- a/markdown/bitburner.ns.hackanalyzethreads.md +++ b/markdown/bitburner.ns.hackanalyzethreads.md @@ -36,7 +36,7 @@ This function returns the decimal number of script threads you need when running ```ts // 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. ns.run("noodleHack.js", Math.floor(hackThreads)) diff --git a/markdown/bitburner.singularity.createprogram.md b/markdown/bitburner.singularity.createprogram.md index fa6af4104..461445b6a 100644 --- a/markdown/bitburner.singularity.createprogram.md +++ b/markdown/bitburner.singularity.createprogram.md @@ -40,7 +40,7 @@ Note that creating a program using this function has the same hacking level requ ```js 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}") ``` diff --git a/markdown/bitburner.singularity.getdarkwebprogramcost.md b/markdown/bitburner.singularity.getdarkwebprogramcost.md index 43bf3626a..f4b98a390 100644 --- a/markdown/bitburner.singularity.getdarkwebprogramcost.md +++ b/markdown/bitburner.singularity.getdarkwebprogramcost.md @@ -37,7 +37,7 @@ If the program does not exist, an error is thrown. ```js const programName = "BruteSSH.exe"; -const cost = ns.getDarkwebProgramCost(programName); -if (cost > 0) ns.tprint(`${programName} costs ${ns.formatMoney(cost)}`); +const cost = ns.singularity.getDarkwebProgramCost(programName); +if (cost > 0) ns.tprint(`${programName} costs $${ns.formatNumber(cost)}`); ``` diff --git a/markdown/bitburner.singularity.getdarkwebprograms.md b/markdown/bitburner.singularity.getdarkwebprograms.md index a6f5404c6..7cd7a648d 100644 --- a/markdown/bitburner.singularity.getdarkwebprograms.md +++ b/markdown/bitburner.singularity.getdarkwebprograms.md @@ -27,7 +27,7 @@ This function allows the player to get a list of programs available for purchase ```js -const programs = ns.getDarkwebPrograms(); +const programs = ns.singularity.getDarkwebPrograms(); ns.tprint(`Available programs are: ${programs.split(", ")}`); ``` diff --git a/markdown/bitburner.singularity.purchaseprogram.md b/markdown/bitburner.singularity.purchaseprogram.md index 35678e8de..8519dea6c 100644 --- a/markdown/bitburner.singularity.purchaseprogram.md +++ b/markdown/bitburner.singularity.purchaseprogram.md @@ -35,7 +35,7 @@ This function allows you to automatically purchase programs. You MUST have a TOR ```js const programName = "BruteSSH.exe" -const success = ns.purchaseProgram(programName); +const success = ns.singularity.purchaseProgram(programName); if (!success) ns.tprint("ERROR: Failed to purchase ${programName}") ``` diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 4b801691e..a5a84427f 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -1798,7 +1798,7 @@ export interface Singularity { * @example * ```js * const programName = "BruteSSH.exe" - * const success = ns.purchaseProgram(programName); + * const success = ns.singularity.purchaseProgram(programName); * if (!success) ns.tprint("ERROR: Failed to purchase ${programName}") * ``` * @param programName - Name of program to purchase. @@ -2229,7 +2229,7 @@ export interface Singularity { * @example * ```js * 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}") * ``` * @param program - Name of program to create. @@ -2536,7 +2536,7 @@ export interface Singularity { * * @example * ```js - * const programs = ns.getDarkwebPrograms(); + * const programs = ns.singularity.getDarkwebPrograms(); * ns.tprint(`Available programs are: ${programs.split(", ")}`); * ``` * @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 * ```js * const programName = "BruteSSH.exe"; - * const cost = ns.getDarkwebProgramCost(programName); - * if (cost > 0) ns.tprint(`${programName} costs ${ns.formatMoney(cost)}`); + * const cost = ns.singularity.getDarkwebProgramCost(programName); + * if (cost > 0) ns.tprint(`${programName} costs $${ns.formatNumber(cost)}`); * ``` * @param programName - Name of program to check the price of * @returns Price of the specified darkweb program @@ -3514,7 +3514,7 @@ export interface CodingContract { * * @example * ```js - * const reward = codingcontract.attempt(yourSolution, filename, hostname); + * const reward = ns.codingcontract.attempt(yourSolution, filename, hostname); * if (reward) { * ns.tprint(`Contract solved successfully! Reward: ${reward}`) * } else ns.tprint("Failed to solve contract.") @@ -5525,7 +5525,7 @@ export interface NS { * @example * ```ts * // 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. * ns.run("noodleHack.js", Math.floor(hackThreads)) @@ -5880,9 +5880,9 @@ export interface NS { * @example * ```ts * let recentScripts = ns.getRecentScripts(); - * let mostRecent = recentScripts.shift() + * let mostRecent = recentScripts.shift(); * if (mostRecent) - * ns.tprint(mostRecent.logs.join('\n')) + * ns.tprint(mostRecent.logs.join('\n')); * ``` * * @returns Array with information about previously killed scripts. @@ -6396,8 +6396,8 @@ export interface NS { * @example * ```js * const mults = ns.getHackingMultipliers(); - * print(`chance: ${mults.chance}`); - * print(`growth: ${mults.growth}`); + * ns.tprint(`chance: ${mults.chance}`); + * ns.tprint(`growth: ${mults.growth}`); * ``` * @returns Object containing the Player’s hacking related multipliers. */ @@ -6644,7 +6644,7 @@ export interface NS { * ```js * const ram = 2 ** 20; * 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). * @returns The cost to purchase a server with the specified amount of ram. @@ -8211,7 +8211,7 @@ export interface Corporation extends WarehouseAPI, OfficeAPI { * ```js * while (true) { * 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}.`); * // Manage the Corporation * }