From 48a7eb364f2f39b9e90daeb4583e91299b9a3019 Mon Sep 17 00:00:00 2001 From: catloversg <152669316+catloversg@users.noreply.github.com> Date: Tue, 28 May 2024 04:42:31 +0700 Subject: [PATCH] DOCUMENTATION: Fix wrong examples in NetscriptDefinitions.d.ts (#1309) --- markdown/bitburner.codingcontract.attempt.md | 6 +- markdown/bitburner.ns.getrecentscripts.md | 2 +- markdown/bitburner.ns.getresetinfo.md | 2 +- markdown/bitburner.ns.grow.md | 2 +- markdown/bitburner.ns.hackanalyzethreads.md | 4 +- markdown/bitburner.ns.printf.md | 2 +- markdown/bitburner.ns.ps.md | 2 +- markdown/bitburner.ns.purchaseserver.md | 2 +- markdown/bitburner.ns.run.md | 2 +- markdown/bitburner.ns.sleep.md | 2 +- markdown/bitburner.ns.spawn.md | 2 +- .../bitburner.singularity.createprogram.md | 2 +- ...itburner.singularity.getdarkwebprograms.md | 2 +- ...ingularity.getfactioninviterequirements.md | 8 ++- .../bitburner.singularity.purchaseprogram.md | 4 +- .../bitburner.singularity.workforfaction.md | 2 +- markdown/bitburner.sleeve.settocommitcrime.md | 4 +- markdown/bitburner.tix.getorders.md | 4 +- markdown/bitburner.userinterface.setstyles.md | 2 +- markdown/bitburner.userinterface.settheme.md | 2 +- src/ScriptEditor/NetscriptDefinitions.d.ts | 58 ++++++++++--------- 21 files changed, 64 insertions(+), 52 deletions(-) diff --git a/markdown/bitburner.codingcontract.attempt.md b/markdown/bitburner.codingcontract.attempt.md index 68c7e1308..bb91e2b1d 100644 --- a/markdown/bitburner.codingcontract.attempt.md +++ b/markdown/bitburner.codingcontract.attempt.md @@ -38,7 +38,9 @@ Attempts to solve the Coding Contract with the provided solution. ```js const reward = ns.codingcontract.attempt(yourSolution, filename, hostname); if (reward) { - ns.tprint(`Contract solved successfully! Reward: ${reward}`) -} else ns.tprint("Failed to solve contract.") + ns.tprint(`Contract solved successfully! Reward: ${reward}`); +} else { + ns.tprint("Failed to solve contract."); +} ``` diff --git a/markdown/bitburner.ns.getrecentscripts.md b/markdown/bitburner.ns.getrecentscripts.md index a2e5030bd..63fffec96 100644 --- a/markdown/bitburner.ns.getrecentscripts.md +++ b/markdown/bitburner.ns.getrecentscripts.md @@ -26,7 +26,7 @@ The most recently killed script is the first element in the array. Note that the ## Example -```ts +```js let recentScripts = ns.getRecentScripts(); let mostRecent = recentScripts.shift(); if (mostRecent) diff --git a/markdown/bitburner.ns.getresetinfo.md b/markdown/bitburner.ns.getresetinfo.md index c1a4d1dd4..2b124555f 100644 --- a/markdown/bitburner.ns.getresetinfo.md +++ b/markdown/bitburner.ns.getresetinfo.md @@ -26,6 +26,6 @@ RAM cost: 1 GB const resetInfo = ns.getResetInfo(); const lastAugReset = resetInfo.lastAugReset; ns.tprint(`The last augmentation reset was: ${new Date(lastAugReset)}`); -ns.tprint(`It has been ${Date.now() - lastAugReset}ms since the last augmentation reset.`); +ns.tprint(`It has been ${Date.now() - lastAugReset} ms since the last augmentation reset.`); ``` diff --git a/markdown/bitburner.ns.grow.md b/markdown/bitburner.ns.grow.md index 45c94bc0a..81ff24cd2 100644 --- a/markdown/bitburner.ns.grow.md +++ b/markdown/bitburner.ns.grow.md @@ -54,6 +54,6 @@ The grow() command requires root access to the target server, but there is no re ```js let currentMoney = ns.getServerMoneyAvailable("n00dles"); -currentMoney *= await ns.grow("foodnstuff"); +currentMoney *= await ns.grow("n00dles"); ``` diff --git a/markdown/bitburner.ns.hackanalyzethreads.md b/markdown/bitburner.ns.hackanalyzethreads.md index e95f783e5..06c696ef1 100644 --- a/markdown/bitburner.ns.hackanalyzethreads.md +++ b/markdown/bitburner.ns.hackanalyzethreads.md @@ -34,12 +34,12 @@ This function returns the decimal number of script threads you need when running ## Example -```ts +```js // Calculate threadcount of a single hack that would take $100k from n00dles 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)) +ns.run("noodleHack.js", Math.floor(hackThreads)); ``` diff --git a/markdown/bitburner.ns.printf.md b/markdown/bitburner.ns.printf.md index a93ad02c0..ef563d783 100644 --- a/markdown/bitburner.ns.printf.md +++ b/markdown/bitburner.ns.printf.md @@ -42,7 +42,7 @@ ns.printf("I'm %d seconds old.", age); ns.printf("My age in binary is %b.", age); ns.printf("My age in scientific notation is %e.", age); ns.printf("In %d seconds, I'll be %s.", 6, "Byte"); -ns.printf("Am I a nibble? %t", (4 == age)); +ns.printf("Am I a nibble? %t", (4 === age)); ns.tail(); ``` diff --git a/markdown/bitburner.ns.ps.md b/markdown/bitburner.ns.ps.md index a3b9e0777..e77b50afb 100644 --- a/markdown/bitburner.ns.ps.md +++ b/markdown/bitburner.ns.ps.md @@ -35,7 +35,7 @@ Returns an array with general information about all scripts running on the speci ```js const ps = ns.ps("home"); -for (let script of ps) { +for (const script of ps) { ns.tprint(`${script.filename} ${script.threads}`); ns.tprint(script.args); } diff --git a/markdown/bitburner.ns.purchaseserver.md b/markdown/bitburner.ns.purchaseserver.md index 1aad09172..4bb096b7f 100644 --- a/markdown/bitburner.ns.purchaseserver.md +++ b/markdown/bitburner.ns.purchaseserver.md @@ -44,7 +44,7 @@ Returns the hostname of the newly purchased server as a string. If the function // Attempt to purchase 5 servers with 64GB of ram each const ram = 64; const prefix = "pserv-"; -for (i = 0; i < 5; ++i) { +for (let i = 0; i < 5; ++i) { ns.purchaseServer(prefix + i, ram); } ``` diff --git a/markdown/bitburner.ns.run.md b/markdown/bitburner.ns.run.md index 974cd043b..bf9682003 100644 --- a/markdown/bitburner.ns.run.md +++ b/markdown/bitburner.ns.run.md @@ -51,6 +51,6 @@ ns.run("foo.js"); ns.run("foo.js", {threads: 5}); //This next example will run ‘foo.js’ single-threaded, and will pass the string ‘foodnstuff’ into the script as an argument: -ns.run("foo.js", 1, 'foodnstuff'); +ns.run("foo.js", 1, "foodnstuff"); ``` diff --git a/markdown/bitburner.ns.sleep.md b/markdown/bitburner.ns.sleep.md index 2bedf4d01..60ab277a8 100644 --- a/markdown/bitburner.ns.sleep.md +++ b/markdown/bitburner.ns.sleep.md @@ -33,7 +33,7 @@ RAM cost: 0 GB ```js // This will count from 1 to 10 in your terminal, with one number every 5 seconds -for (var i = 1; i <= 10; i++) { +for (let i = 1; i <= 10; ++i) { ns.tprint(i); await ns.sleep(5000); } diff --git a/markdown/bitburner.ns.spawn.md b/markdown/bitburner.ns.spawn.md index 46424bbb6..eb5cf9c66 100644 --- a/markdown/bitburner.ns.spawn.md +++ b/markdown/bitburner.ns.spawn.md @@ -39,6 +39,6 @@ Running this function with 0 or fewer threads will cause a runtime error. ```js //The following example will execute the script ‘foo.js’ with 10 threads, in 500 milliseconds and the arguments ‘foodnstuff’ and 90: -ns.spawn('foo.js', {threads: 10, spawnDelay: 500}, 'foodnstuff', 90); +ns.spawn("foo.js", {threads: 10, spawnDelay: 500}, "foodnstuff", 90); ``` diff --git a/markdown/bitburner.singularity.createprogram.md b/markdown/bitburner.singularity.createprogram.md index 461445b6a..b53488d74 100644 --- a/markdown/bitburner.singularity.createprogram.md +++ b/markdown/bitburner.singularity.createprogram.md @@ -41,6 +41,6 @@ Note that creating a program using this function has the same hacking level requ ```js const programName = "BruteSSH.exe"; 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}`); ``` diff --git a/markdown/bitburner.singularity.getdarkwebprograms.md b/markdown/bitburner.singularity.getdarkwebprograms.md index 7cd7a648d..9372aec13 100644 --- a/markdown/bitburner.singularity.getdarkwebprograms.md +++ b/markdown/bitburner.singularity.getdarkwebprograms.md @@ -28,6 +28,6 @@ This function allows the player to get a list of programs available for purchase ```js const programs = ns.singularity.getDarkwebPrograms(); -ns.tprint(`Available programs are: ${programs.split(", ")}`); +ns.tprint(`Available programs are: ${programs}`); ``` diff --git a/markdown/bitburner.singularity.getfactioninviterequirements.md b/markdown/bitburner.singularity.getfactioninviterequirements.md index a89111729..198000f46 100644 --- a/markdown/bitburner.singularity.getfactioninviterequirements.md +++ b/markdown/bitburner.singularity.getfactioninviterequirements.md @@ -32,7 +32,8 @@ RAM cost: 3 GB \* 16/4/1 ```js -ns.singularity.getFactionInviteRequirements("The Syndicate") +ns.singularity.getFactionInviteRequirements("The Syndicate"); + [ { "type": "someCondition", "conditions": [ { "type": "city", "city": "Aevum" }, @@ -49,7 +50,10 @@ ns.singularity.getFactionInviteRequirements("The Syndicate") }, { "type": "money", "money": 10000000 }, { "type": "skills", "skills": { "hacking": 200 } }, - { "type": "skills", "skills": { "strength": 200, "defense": 200, "dexterity": 200, "agility": 200 } }, + { "type": "skills", "skills": { "strength": 200 } }, + { "type": "skills", "skills": { "defense": 200 } }, + { "type": "skills", "skills": { "dexterity": 200 } }, + { "type": "skills", "skills": { "agility": 200 } }, { "type": "karma", "karma": -90 } ] ``` diff --git a/markdown/bitburner.singularity.purchaseprogram.md b/markdown/bitburner.singularity.purchaseprogram.md index 8519dea6c..bb419c5ce 100644 --- a/markdown/bitburner.singularity.purchaseprogram.md +++ b/markdown/bitburner.singularity.purchaseprogram.md @@ -34,8 +34,8 @@ This function allows you to automatically purchase programs. You MUST have a TOR ```js -const programName = "BruteSSH.exe" +const programName = "BruteSSH.exe"; const success = ns.singularity.purchaseProgram(programName); -if (!success) ns.tprint("ERROR: Failed to purchase ${programName}") +if (!success) ns.tprint(`ERROR: Failed to purchase ${programName}`); ``` diff --git a/markdown/bitburner.singularity.workforfaction.md b/markdown/bitburner.singularity.workforfaction.md index 259875de7..d31622238 100644 --- a/markdown/bitburner.singularity.workforfaction.md +++ b/markdown/bitburner.singularity.workforfaction.md @@ -42,6 +42,6 @@ const factionName = "CyberSec"; const workType = "hacking"; let success = ns.singularity.workForFaction(factionName, workType); -if (!success) ns.tprint(`ERROR: Failed to start work for ${factionName} with work type ${workType}.`) +if (!success) ns.tprint(`ERROR: Failed to start work for ${factionName} with work type ${workType}.`); ``` diff --git a/markdown/bitburner.sleeve.settocommitcrime.md b/markdown/bitburner.sleeve.settocommitcrime.md index b7973a647..1bd09b37c 100644 --- a/markdown/bitburner.sleeve.settocommitcrime.md +++ b/markdown/bitburner.sleeve.settocommitcrime.md @@ -34,12 +34,12 @@ Return a boolean indicating whether or not this action was set successfully (fal ## Example -```ts +```js // Assigns the first sleeve to Homicide. ns.sleeve.setToCommitCrime(0, "Homicide"); // Assigns the second sleeve to Grand Theft Auto, using enum const crimes = ns.enums.CrimeType; -ns.sleeve.setToCommitCrime(1, crimes.grandTheftAuto) +ns.sleeve.setToCommitCrime(1, crimes.grandTheftAuto); ``` diff --git a/markdown/bitburner.tix.getorders.md b/markdown/bitburner.tix.getorders.md index 376f4cf70..c4ff82daa 100644 --- a/markdown/bitburner.tix.getorders.md +++ b/markdown/bitburner.tix.getorders.md @@ -21,7 +21,7 @@ Object containing information for all the Limit and Stop Orders you have in the RAM cost: 2.5 GB This is an object containing information for all the Limit and Stop Orders you have in the stock market. For each symbol you have a position in, the returned object will have a key with that symbol's name. The object's properties are each an array of [StockOrderObject](./bitburner.stockorderobject.md) The object has the following structure: -```ts +```js { string1: [ // Array of orders for this stock { @@ -46,7 +46,7 @@ The “Order type” property can have one of the following four values: "Limit ## Example -```ts +```js "If you do not have orders in Nova Medical (NVMD), then the returned object will not have a “NVMD” property." { ECP: [ diff --git a/markdown/bitburner.userinterface.setstyles.md b/markdown/bitburner.userinterface.setstyles.md index 9d166c529..9feddb91a 100644 --- a/markdown/bitburner.userinterface.setstyles.md +++ b/markdown/bitburner.userinterface.setstyles.md @@ -30,7 +30,7 @@ RAM cost: 0 GB Usage example (NS2) -```ts +```js const styles = ns.ui.getStyles(); styles.fontFamily = 'Comic Sans Ms'; ns.ui.setStyles(styles); diff --git a/markdown/bitburner.userinterface.settheme.md b/markdown/bitburner.userinterface.settheme.md index 1ce3e9acb..307a0bc8e 100644 --- a/markdown/bitburner.userinterface.settheme.md +++ b/markdown/bitburner.userinterface.settheme.md @@ -30,7 +30,7 @@ RAM cost: 0 GB Usage example (NS2) -```ts +```js const theme = ns.ui.getTheme(); theme.primary = '#ff5500'; ns.ui.setTheme(theme); diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 176545ef7..478a45a38 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -1449,7 +1449,7 @@ export interface TIX { * The object's properties are each an array of {@link StockOrderObject} * The object has the following structure: * - * ```ts + * ```js * { * string1: [ // Array of orders for this stock * { @@ -1474,7 +1474,7 @@ export interface TIX { * Note that the order book will only contain information for stocks that you actually have orders in. * * @example - * ```ts + * ```js * "If you do not have orders in Nova Medical (NVMD), then the returned object will not have a “NVMD” property." * { * ECP: [ @@ -1797,9 +1797,9 @@ export interface Singularity { * * @example * ```js - * const programName = "BruteSSH.exe" + * const programName = "BruteSSH.exe"; * 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. * @returns True if the specified program is purchased, and false otherwise. @@ -2053,7 +2053,8 @@ export interface Singularity { * * @example * ```js - * ns.singularity.getFactionInviteRequirements("The Syndicate") + * ns.singularity.getFactionInviteRequirements("The Syndicate"); + * * [ * { "type": "someCondition", "conditions": [ * { "type": "city", "city": "Aevum" }, @@ -2070,7 +2071,10 @@ export interface Singularity { * }, * { "type": "money", "money": 10000000 }, * { "type": "skills", "skills": { "hacking": 200 } }, - * { "type": "skills", "skills": { "strength": 200, "defense": 200, "dexterity": 200, "agility": 200 } }, + * { "type": "skills", "skills": { "strength": 200 } }, + * { "type": "skills", "skills": { "defense": 200 } }, + * { "type": "skills", "skills": { "dexterity": 200 } }, + * { "type": "skills", "skills": { "agility": 200 } }, * { "type": "karma", "karma": -90 } * ] * ``` @@ -2136,7 +2140,7 @@ export interface Singularity { * const workType = "hacking"; * * let success = ns.singularity.workForFaction(factionName, workType); - * if (!success) ns.tprint(`ERROR: Failed to start work for ${factionName} with work type ${workType}.`) + * if (!success) ns.tprint(`ERROR: Failed to start work for ${factionName} with work type ${workType}.`); * ``` * @param faction - Name of faction to work for. * @param workType - Type of work to perform for the faction. @@ -2230,7 +2234,7 @@ export interface Singularity { * ```js * const programName = "BruteSSH.exe"; * 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 focus - Acquire player focus on this program creation. Optional. Defaults to true. @@ -2537,7 +2541,7 @@ export interface Singularity { * @example * ```js * const programs = ns.singularity.getDarkwebPrograms(); - * ns.tprint(`Available programs are: ${programs.split(", ")}`); + * ns.tprint(`Available programs are: ${programs}`); * ``` * @returns - a list of programs available for purchase on the dark web, or [] if Tor has not * been purchased @@ -3516,8 +3520,10 @@ export interface CodingContract { * ```js * const reward = ns.codingcontract.attempt(yourSolution, filename, hostname); * if (reward) { - * ns.tprint(`Contract solved successfully! Reward: ${reward}`) - * } else ns.tprint("Failed to solve contract.") + * ns.tprint(`Contract solved successfully! Reward: ${reward}`); + * } else { + * ns.tprint("Failed to solve contract."); + * } * ``` * * @param answer - Attempted solution for the contract. @@ -4398,13 +4404,13 @@ export interface Sleeve { * Return a boolean indicating whether or not this action was set successfully (false if an invalid action is specified). * * @example - * ```ts + * ```js * // Assigns the first sleeve to Homicide. * ns.sleeve.setToCommitCrime(0, "Homicide"); * * // Assigns the second sleeve to Grand Theft Auto, using enum * const crimes = ns.enums.CrimeType; - * ns.sleeve.setToCommitCrime(1, crimes.grandTheftAuto) + * ns.sleeve.setToCommitCrime(1, crimes.grandTheftAuto); * ``` * * @param sleeveNumber - Index of the sleeve to start committing crime. Sleeves are numbered starting from 0. @@ -5211,7 +5217,7 @@ interface UserInterface { * RAM cost: 0 GB * @example * Usage example (NS2) - * ```ts + * ```js * const theme = ns.ui.getTheme(); * theme.primary = '#ff5500'; * ns.ui.setTheme(theme); @@ -5241,7 +5247,7 @@ interface UserInterface { * RAM cost: 0 GB * @example * Usage example (NS2) - * ```ts + * ```js * const styles = ns.ui.getStyles(); * styles.fontFamily = 'Comic Sans Ms'; * ns.ui.setStyles(styles); @@ -5466,7 +5472,7 @@ export interface NS { * @example * ```js * let currentMoney = ns.getServerMoneyAvailable("n00dles"); - * currentMoney *= await ns.grow("foodnstuff"); + * currentMoney *= await ns.grow("n00dles"); * ``` * @param host - Hostname of the target server to grow. * @param opts - Optional parameters for configuring function behavior. @@ -5523,12 +5529,12 @@ export interface NS { * * * @example - * ```ts + * ```js * // Calculate threadcount of a single hack that would take $100k from n00dles * 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)) + * ns.run("noodleHack.js", Math.floor(hackThreads)); * * ``` * @param host - Hostname of the target server to analyze. @@ -5652,7 +5658,7 @@ export interface NS { * @example * ```js * // This will count from 1 to 10 in your terminal, with one number every 5 seconds - * for (var i = 1; i <= 10; i++) { + * for (let i = 1; i <= 10; ++i) { * ns.tprint(i); * await ns.sleep(5000); * } @@ -5750,7 +5756,7 @@ export interface NS { * ns.printf("My age in binary is %b.", age); * ns.printf("My age in scientific notation is %e.", age); * ns.printf("In %d seconds, I'll be %s.", 6, "Byte"); - * ns.printf("Am I a nibble? %t", (4 == age)); + * ns.printf("Am I a nibble? %t", (4 === age)); * ns.tail(); * ``` * @@ -5878,7 +5884,7 @@ export interface NS { * This is configurable in the game's options as `Recently killed scripts size`. * * @example - * ```ts + * ```js * let recentScripts = ns.getRecentScripts(); * let mostRecent = recentScripts.shift(); * if (mostRecent) @@ -6143,7 +6149,7 @@ export interface NS { * ns.run("foo.js", {threads: 5}); * * //This next example will run ‘foo.js’ single-threaded, and will pass the string ‘foodnstuff’ into the script as an argument: - * ns.run("foo.js", 1, 'foodnstuff'); + * ns.run("foo.js", 1, "foodnstuff"); * ``` * @param script - Filename of script to run. * @param threadOrOptions - Either an integer number of threads for new script, or a {@link RunOptions} object. Threads defaults to 1. @@ -6209,7 +6215,7 @@ export interface NS { * @example * ```js * //The following example will execute the script ‘foo.js’ with 10 threads, in 500 milliseconds and the arguments ‘foodnstuff’ and 90: - * ns.spawn('foo.js', {threads: 10, spawnDelay: 500}, 'foodnstuff', 90); + * ns.spawn("foo.js", {threads: 10, spawnDelay: 500}, "foodnstuff", 90); * ``` * @param script - Filename of script to execute. * @param threadOrOptions - Either an integer number of threads for new script, or a {@link SpawnOptions} object. Threads defaults to 1 and spawnDelay defaults to 10,000 ms. @@ -6338,7 +6344,7 @@ export interface NS { * @example * ```js * const ps = ns.ps("home"); - * for (let script of ps) { + * for (const script of ps) { * ns.tprint(`${script.filename} ${script.threads}`); * ns.tprint(script.args); * } @@ -6680,7 +6686,7 @@ export interface NS { * // Attempt to purchase 5 servers with 64GB of ram each * const ram = 64; * const prefix = "pserv-"; - * for (i = 0; i < 5; ++i) { + * for (let i = 0; i < 5; ++i) { * ns.purchaseServer(prefix + i, ram); * } * ``` @@ -7392,7 +7398,7 @@ export interface NS { * const resetInfo = ns.getResetInfo(); * const lastAugReset = resetInfo.lastAugReset; * ns.tprint(`The last augmentation reset was: ${new Date(lastAugReset)}`); - * ns.tprint(`It has been ${Date.now() - lastAugReset}ms since the last augmentation reset.`); + * ns.tprint(`It has been ${Date.now() - lastAugReset} ms since the last augmentation reset.`); * ``` * */ getResetInfo(): ResetInfo;