mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 12:15:44 +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
|
```js
|
||||||
const reward = ns.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.");
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ The most recently killed script is the first element in the array. Note that the
|
|||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
|
||||||
```ts
|
```js
|
||||||
let recentScripts = ns.getRecentScripts();
|
let recentScripts = ns.getRecentScripts();
|
||||||
let mostRecent = recentScripts.shift();
|
let mostRecent = recentScripts.shift();
|
||||||
if (mostRecent)
|
if (mostRecent)
|
||||||
|
@ -54,6 +54,6 @@ The grow() command requires root access to the target server, but there is no re
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
let currentMoney = ns.getServerMoneyAvailable("n00dles");
|
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
|
## Example
|
||||||
|
|
||||||
|
|
||||||
```ts
|
```js
|
||||||
// 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 = ns.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));
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -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 binary is %b.", age);
|
||||||
ns.printf("My age in scientific notation is %e.", age);
|
ns.printf("My age in scientific notation is %e.", age);
|
||||||
ns.printf("In %d seconds, I'll be %s.", 6, "Byte");
|
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();
|
ns.tail();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ Returns an array with general information about all scripts running on the speci
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const ps = ns.ps("home");
|
const ps = ns.ps("home");
|
||||||
for (let script of ps) {
|
for (const script of ps) {
|
||||||
ns.tprint(`${script.filename} ${script.threads}`);
|
ns.tprint(`${script.filename} ${script.threads}`);
|
||||||
ns.tprint(script.args);
|
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
|
// Attempt to purchase 5 servers with 64GB of ram each
|
||||||
const ram = 64;
|
const ram = 64;
|
||||||
const prefix = "pserv-";
|
const prefix = "pserv-";
|
||||||
for (i = 0; i < 5; ++i) {
|
for (let i = 0; i < 5; ++i) {
|
||||||
ns.purchaseServer(prefix + i, ram);
|
ns.purchaseServer(prefix + i, ram);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -51,6 +51,6 @@ ns.run("foo.js");
|
|||||||
ns.run("foo.js", {threads: 5});
|
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:
|
//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
|
```js
|
||||||
// This will count from 1 to 10 in your terminal, with one number every 5 seconds
|
// 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);
|
ns.tprint(i);
|
||||||
await ns.sleep(5000);
|
await ns.sleep(5000);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,6 @@ Running this function with 0 or fewer threads will cause a runtime error.
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
//The following example will execute the script ‘foo.js’ with 10 threads, in 500 milliseconds and the arguments ‘foodnstuff’ and 90:
|
//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
|
```js
|
||||||
const programName = "BruteSSH.exe";
|
const programName = "BruteSSH.exe";
|
||||||
const success = ns.singularity.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}`);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -28,6 +28,6 @@ This function allows the player to get a list of programs available for purchase
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const programs = ns.singularity.getDarkwebPrograms();
|
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
|
```js
|
||||||
ns.singularity.getFactionInviteRequirements("The Syndicate")
|
ns.singularity.getFactionInviteRequirements("The Syndicate");
|
||||||
|
|
||||||
[
|
[
|
||||||
{ "type": "someCondition", "conditions": [
|
{ "type": "someCondition", "conditions": [
|
||||||
{ "type": "city", "city": "Aevum" },
|
{ "type": "city", "city": "Aevum" },
|
||||||
@ -49,7 +50,10 @@ ns.singularity.getFactionInviteRequirements("The Syndicate")
|
|||||||
},
|
},
|
||||||
{ "type": "money", "money": 10000000 },
|
{ "type": "money", "money": 10000000 },
|
||||||
{ "type": "skills", "skills": { "hacking": 200 } },
|
{ "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 }
|
{ "type": "karma", "karma": -90 }
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
@ -34,8 +34,8 @@ 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.singularity.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}`);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -42,6 +42,6 @@ const factionName = "CyberSec";
|
|||||||
const workType = "hacking";
|
const workType = "hacking";
|
||||||
|
|
||||||
let success = ns.singularity.workForFaction(factionName, workType);
|
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
|
## Example
|
||||||
|
|
||||||
|
|
||||||
```ts
|
```js
|
||||||
// Assigns the first sleeve to Homicide.
|
// Assigns the first sleeve to Homicide.
|
||||||
ns.sleeve.setToCommitCrime(0, "Homicide");
|
ns.sleeve.setToCommitCrime(0, "Homicide");
|
||||||
|
|
||||||
// Assigns the second sleeve to Grand Theft Auto, using enum
|
// Assigns the second sleeve to Grand Theft Auto, using enum
|
||||||
const crimes = ns.enums.CrimeType;
|
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:
|
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
|
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
|
## Example
|
||||||
|
|
||||||
|
|
||||||
```ts
|
```js
|
||||||
"If you do not have orders in Nova Medical (NVMD), then the returned object will not have a “NVMD” property."
|
"If you do not have orders in Nova Medical (NVMD), then the returned object will not have a “NVMD” property."
|
||||||
{
|
{
|
||||||
ECP: [
|
ECP: [
|
||||||
|
@ -30,7 +30,7 @@ RAM cost: 0 GB
|
|||||||
|
|
||||||
Usage example (NS2)
|
Usage example (NS2)
|
||||||
|
|
||||||
```ts
|
```js
|
||||||
const styles = ns.ui.getStyles();
|
const styles = ns.ui.getStyles();
|
||||||
styles.fontFamily = 'Comic Sans Ms';
|
styles.fontFamily = 'Comic Sans Ms';
|
||||||
ns.ui.setStyles(styles);
|
ns.ui.setStyles(styles);
|
||||||
|
@ -30,7 +30,7 @@ RAM cost: 0 GB
|
|||||||
|
|
||||||
Usage example (NS2)
|
Usage example (NS2)
|
||||||
|
|
||||||
```ts
|
```js
|
||||||
const theme = ns.ui.getTheme();
|
const theme = ns.ui.getTheme();
|
||||||
theme.primary = '#ff5500';
|
theme.primary = '#ff5500';
|
||||||
ns.ui.setTheme(theme);
|
ns.ui.setTheme(theme);
|
||||||
|
56
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
56
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's properties are each an array of {@link StockOrderObject}
|
||||||
* The object has the following structure:
|
* The object has the following structure:
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```js
|
||||||
* {
|
* {
|
||||||
* string1: [ // Array of orders for this stock
|
* 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.
|
* Note that the order book will only contain information for stocks that you actually have orders in.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```js
|
||||||
* "If you do not have orders in Nova Medical (NVMD), then the returned object will not have a “NVMD” property."
|
* "If you do not have orders in Nova Medical (NVMD), then the returned object will not have a “NVMD” property."
|
||||||
* {
|
* {
|
||||||
* ECP: [
|
* ECP: [
|
||||||
@ -1797,9 +1797,9 @@ export interface Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```js
|
* ```js
|
||||||
* const programName = "BruteSSH.exe"
|
* const programName = "BruteSSH.exe";
|
||||||
* const success = ns.singularity.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.
|
||||||
* @returns True if the specified program is purchased, and false otherwise.
|
* @returns True if the specified program is purchased, and false otherwise.
|
||||||
@ -2053,7 +2053,8 @@ export interface Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```js
|
* ```js
|
||||||
* ns.singularity.getFactionInviteRequirements("The Syndicate")
|
* ns.singularity.getFactionInviteRequirements("The Syndicate");
|
||||||
|
*
|
||||||
* [
|
* [
|
||||||
* { "type": "someCondition", "conditions": [
|
* { "type": "someCondition", "conditions": [
|
||||||
* { "type": "city", "city": "Aevum" },
|
* { "type": "city", "city": "Aevum" },
|
||||||
@ -2070,7 +2071,10 @@ export interface Singularity {
|
|||||||
* },
|
* },
|
||||||
* { "type": "money", "money": 10000000 },
|
* { "type": "money", "money": 10000000 },
|
||||||
* { "type": "skills", "skills": { "hacking": 200 } },
|
* { "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 }
|
* { "type": "karma", "karma": -90 }
|
||||||
* ]
|
* ]
|
||||||
* ```
|
* ```
|
||||||
@ -2136,7 +2140,7 @@ export interface Singularity {
|
|||||||
* const workType = "hacking";
|
* const workType = "hacking";
|
||||||
*
|
*
|
||||||
* let success = ns.singularity.workForFaction(factionName, workType);
|
* 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 faction - Name of faction to work for.
|
||||||
* @param workType - Type of work to perform for the faction.
|
* @param workType - Type of work to perform for the faction.
|
||||||
@ -2230,7 +2234,7 @@ export interface Singularity {
|
|||||||
* ```js
|
* ```js
|
||||||
* const programName = "BruteSSH.exe";
|
* const programName = "BruteSSH.exe";
|
||||||
* const success = ns.singularity.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.
|
||||||
* @param focus - Acquire player focus on this program creation. Optional. Defaults to true.
|
* @param focus - Acquire player focus on this program creation. Optional. Defaults to true.
|
||||||
@ -2537,7 +2541,7 @@ export interface Singularity {
|
|||||||
* @example
|
* @example
|
||||||
* ```js
|
* ```js
|
||||||
* const programs = ns.singularity.getDarkwebPrograms();
|
* 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
|
* @returns - a list of programs available for purchase on the dark web, or [] if Tor has not
|
||||||
* been purchased
|
* been purchased
|
||||||
@ -3516,8 +3520,10 @@ export interface CodingContract {
|
|||||||
* ```js
|
* ```js
|
||||||
* const reward = ns.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.");
|
||||||
|
* }
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @param answer - Attempted solution for the 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).
|
* Return a boolean indicating whether or not this action was set successfully (false if an invalid action is specified).
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```js
|
||||||
* // Assigns the first sleeve to Homicide.
|
* // Assigns the first sleeve to Homicide.
|
||||||
* ns.sleeve.setToCommitCrime(0, "Homicide");
|
* ns.sleeve.setToCommitCrime(0, "Homicide");
|
||||||
*
|
*
|
||||||
* // Assigns the second sleeve to Grand Theft Auto, using enum
|
* // Assigns the second sleeve to Grand Theft Auto, using enum
|
||||||
* const crimes = ns.enums.CrimeType;
|
* 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.
|
* @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
|
* RAM cost: 0 GB
|
||||||
* @example
|
* @example
|
||||||
* Usage example (NS2)
|
* Usage example (NS2)
|
||||||
* ```ts
|
* ```js
|
||||||
* const theme = ns.ui.getTheme();
|
* const theme = ns.ui.getTheme();
|
||||||
* theme.primary = '#ff5500';
|
* theme.primary = '#ff5500';
|
||||||
* ns.ui.setTheme(theme);
|
* ns.ui.setTheme(theme);
|
||||||
@ -5241,7 +5247,7 @@ interface UserInterface {
|
|||||||
* RAM cost: 0 GB
|
* RAM cost: 0 GB
|
||||||
* @example
|
* @example
|
||||||
* Usage example (NS2)
|
* Usage example (NS2)
|
||||||
* ```ts
|
* ```js
|
||||||
* const styles = ns.ui.getStyles();
|
* const styles = ns.ui.getStyles();
|
||||||
* styles.fontFamily = 'Comic Sans Ms';
|
* styles.fontFamily = 'Comic Sans Ms';
|
||||||
* ns.ui.setStyles(styles);
|
* ns.ui.setStyles(styles);
|
||||||
@ -5466,7 +5472,7 @@ export interface NS {
|
|||||||
* @example
|
* @example
|
||||||
* ```js
|
* ```js
|
||||||
* let currentMoney = ns.getServerMoneyAvailable("n00dles");
|
* 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 host - Hostname of the target server to grow.
|
||||||
* @param opts - Optional parameters for configuring function behavior.
|
* @param opts - Optional parameters for configuring function behavior.
|
||||||
@ -5523,12 +5529,12 @@ export interface NS {
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```js
|
||||||
* // 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 = ns.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));
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @param host - Hostname of the target server to analyze.
|
* @param host - Hostname of the target server to analyze.
|
||||||
@ -5652,7 +5658,7 @@ export interface NS {
|
|||||||
* @example
|
* @example
|
||||||
* ```js
|
* ```js
|
||||||
* // This will count from 1 to 10 in your terminal, with one number every 5 seconds
|
* // 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);
|
* ns.tprint(i);
|
||||||
* await ns.sleep(5000);
|
* 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 binary is %b.", age);
|
||||||
* ns.printf("My age in scientific notation is %e.", age);
|
* ns.printf("My age in scientific notation is %e.", age);
|
||||||
* ns.printf("In %d seconds, I'll be %s.", 6, "Byte");
|
* 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();
|
* ns.tail();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
@ -5878,7 +5884,7 @@ export interface NS {
|
|||||||
* This is configurable in the game's options as `Recently killed scripts size`.
|
* This is configurable in the game's options as `Recently killed scripts size`.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```js
|
||||||
* let recentScripts = ns.getRecentScripts();
|
* let recentScripts = ns.getRecentScripts();
|
||||||
* let mostRecent = recentScripts.shift();
|
* let mostRecent = recentScripts.shift();
|
||||||
* if (mostRecent)
|
* if (mostRecent)
|
||||||
@ -6143,7 +6149,7 @@ export interface NS {
|
|||||||
* ns.run("foo.js", {threads: 5});
|
* 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:
|
* //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 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.
|
* @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
|
* @example
|
||||||
* ```js
|
* ```js
|
||||||
* //The following example will execute the script ‘foo.js’ with 10 threads, in 500 milliseconds and the arguments ‘foodnstuff’ and 90:
|
* //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 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.
|
* @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
|
* @example
|
||||||
* ```js
|
* ```js
|
||||||
* const ps = ns.ps("home");
|
* const ps = ns.ps("home");
|
||||||
* for (let script of ps) {
|
* for (const script of ps) {
|
||||||
* ns.tprint(`${script.filename} ${script.threads}`);
|
* ns.tprint(`${script.filename} ${script.threads}`);
|
||||||
* ns.tprint(script.args);
|
* ns.tprint(script.args);
|
||||||
* }
|
* }
|
||||||
@ -6680,7 +6686,7 @@ export interface NS {
|
|||||||
* // Attempt to purchase 5 servers with 64GB of ram each
|
* // Attempt to purchase 5 servers with 64GB of ram each
|
||||||
* const ram = 64;
|
* const ram = 64;
|
||||||
* const prefix = "pserv-";
|
* const prefix = "pserv-";
|
||||||
* for (i = 0; i < 5; ++i) {
|
* for (let i = 0; i < 5; ++i) {
|
||||||
* ns.purchaseServer(prefix + i, ram);
|
* ns.purchaseServer(prefix + i, ram);
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
Loading…
Reference in New Issue
Block a user