mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-08 08:43:53 +01:00
DOCUMENTATION: Fix wrong examples in NetscriptDefinitions.d.ts (#1309)
This commit is contained in:
parent
70521c9156
commit
48a7eb364f
@ -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.");
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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.`);
|
||||
```
|
||||
|
||||
|
@ -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");
|
||||
```
|
||||
|
||||
|
@ -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));
|
||||
|
||||
```
|
||||
|
||||
|
@ -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();
|
||||
```
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
```
|
||||
|
@ -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");
|
||||
```
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
```
|
||||
|
||||
|
@ -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}`);
|
||||
```
|
||||
|
||||
|
@ -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}`);
|
||||
```
|
||||
|
||||
|
@ -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 }
|
||||
]
|
||||
```
|
||||
|
@ -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}`);
|
||||
```
|
||||
|
||||
|
@ -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}.`);
|
||||
```
|
||||
|
||||
|
@ -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);
|
||||
```
|
||||
|
||||
|
@ -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: [
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
58
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
58
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user