mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 23:08:36 +02:00
DOCUMENTATION: Fix wrong examples in NetscriptDefinitions.d.ts (#1309)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user