mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-09-07 22:56:48 +02:00
Massive doc update
This commit is contained in:
parent
4eef9eec03
commit
fd3655a2fa
@ -28,11 +28,11 @@ The general logic goes like this:
|
||||
|
||||
loop forever {
|
||||
if security is not minimum {
|
||||
weaken(target)
|
||||
await ns.weaken(target)
|
||||
} else if money is not maximum {
|
||||
grow(target)
|
||||
await ns.grow(target)
|
||||
} else {
|
||||
hack(target)
|
||||
await ns.hack(target)
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ By splitting our hack, weaken, and grow functions into three separate scripts, w
|
||||
.. code-block:: javascript
|
||||
|
||||
loop forever {
|
||||
hack(target) // or grow, or weaken
|
||||
await ns.hack(target) // or grow, or weaken
|
||||
}
|
||||
|
||||
Now we can take the total amount of threads available and split it and allocate, for example:
|
||||
@ -95,8 +95,8 @@ The scripts used to execute the hacking functions are even simpler than the prev
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
sleep(a bit)
|
||||
hack(target) // or grow, or weaken
|
||||
await ns.sleep(a bit)
|
||||
await ns.hack(target) // or grow, or weaken
|
||||
|
||||
A few things need to be known before this algorithm can be implemented:
|
||||
|
||||
|
@ -10,7 +10,7 @@ than 'sleeves' for the human consciousness. This technology thus became known as
|
||||
Sleeve technology unlocks two different gameplay features:
|
||||
|
||||
* Duplicate Sleeves
|
||||
* Re-sleeving
|
||||
* Grafting
|
||||
|
||||
Sleeve technology is unlocked in :ref:`BitNode-10 <gameplay_bitnodes>`.
|
||||
|
||||
@ -48,11 +48,6 @@ Synchronization is a measure of how aligned your consciousness is with that of y
|
||||
Duplicate Sleeves. It is a numerical value between 1 and 100, and it affects how much experience
|
||||
is earned when the sleeve is performing a task.
|
||||
|
||||
Let N be the sleeve's synchronization. When the sleeve earns experience by performing
|
||||
a task, both the sleeve and the player's original host consciousness gain N% of the
|
||||
amount of experience normally earned by the task. All of the player's other sleeves
|
||||
earn ((N/100)^2 * 100)% of the experience.
|
||||
|
||||
Synchronization can be increased by assigning sleeves to the 'Synchronize' task.
|
||||
|
||||
Sleeve Shock
|
||||
@ -64,6 +59,10 @@ no shock. Shock affects the amount of experience earned by the sleeve.
|
||||
Sleeve shock slowly decreases over time. You can further increase the rate at which
|
||||
it decreases by assigning sleeves to the 'Shock Recovery' task.
|
||||
|
||||
Let X be the sleeve's shock and Y be the sleeve's synchronization. When the sleeve earns experience by performing
|
||||
a task, the sleeve gains X% of the amount of experience normally earned by the task. player’s original host consciousness and all of the player's other sleeves
|
||||
earn Y% of the experience that the sleeve gained, or X*Y % of the normal experience amount.
|
||||
|
||||
Augmentations
|
||||
~~~~~~~~~~~~~
|
||||
You can purchase :ref:`Augmentations <gameplay_augmentations>` for your Duplicate
|
||||
@ -90,3 +89,6 @@ the ability to purchase additional sleeves, this is only available in BitNode-10
|
||||
|
||||
Memory is a persistent stat, meaning it never gets reset back to 1.
|
||||
The maximum possible value for a sleeve's memory is 100.
|
||||
|
||||
Buying memory has no instant affect on synchronization,
|
||||
memory affects only the starting synchronization upon entering a BitNode.
|
@ -10,61 +10,53 @@ in the game and each BitNode will grant a different Source-File when it is destr
|
||||
|
||||
A Source-File can be upgraded by destroying its corresponding BitNode a second or
|
||||
third time (AKA playing through that BitNode again). It can be upgraded to a maximum
|
||||
of level 3.
|
||||
of level 3, with the exception of source-file 12, which has no hard limit.
|
||||
|
||||
List of all Source-Files
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|| BitNode-1: Source Genesis || * Let the player start with 32 GB of RAM on the home computer. |
|
||||
|| || * Increases all of the player's multipliers by 16%/24%/28%. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|| BitNode-2: Rise of the Underworld || * Let the player create Gangs in other BitNodes (although some |
|
||||
|| || BitNodes will disable this mechanic). |
|
||||
|| || * Increases the player's crime success rate, crime money, and |
|
||||
|| || charisma multipliers by 24%/36%/42%. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|| BitNode-3: Corporatocracy || * Let the player create Corporations in other BitNodes (although some |
|
||||
|| || BitNodes will disable this mechanic). |
|
||||
|| || * Increases the player's charisma and company salary multipliers by 8%/12%/14%. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|| BitNode-4: The Singularity || * Let the player access and use Netscript Singularity Functions in other BitNodes. |
|
||||
|| || * Each level of this Source-File reduces the RAM cost of singularity functions. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|| BitNode-5: Artificial Intelligence || * Unlocks :ref:`gameplay_intelligence`. |
|
||||
|| || * Unlocks :js:func:`getBitNodeMultipliers` and start with Formulas.exe. |
|
||||
|| || * Increases all of the player's hacking-related multipliers by 8%/12%/14%. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|| BitNode-6: Bladeburners || * Unlocks the Bladeburner feature in other BitNodes. |
|
||||
|| || * Increases all of the player's level and experience gain rate multipliers for |
|
||||
|| || combat stats by 8%/12%/14%. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|| BitNode-7: Bladeburners 2079 || * Allows the player to access the `Bladeburner API <https://github.com/bitburner-official/bitburner-src/blob/dev/markdown/bitburner.bladeburner.md>`_ in other BitNodes. |
|
||||
|| || * Increases all of the player's Bladeburner multipliers by 8%/12%/14%. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|| BitNode-8: Ghost of Wall Street || * Increases the player's hacking growth multiplier by 12%/18%/21%. |
|
||||
|| || * Level 1 grants permanent access to :ref:`WSE <gameplay_stock_market>` and the `TIX API <https://github.com/bitburner-official/bitburner-src/blob/dev/markdown/bitburner.tix.md>`_ |
|
||||
|| || * Level 2 grants permanent access to shorting stocks. |
|
||||
|| || * Level 3 grants permanent access to use limit/stop orders. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|| BitNode-9: Hacktocracy || * Level 1 permanently unlocks the Hacknet Server in other BitNodes. |
|
||||
|| || * Level 2 lets the player start with 128 GB of RAM on the home computer. |
|
||||
|| || * Level 3 grants a highly-upgraded Hacknet Server when entering a new BitNode (it |
|
||||
|| || will be lost after installing augments). |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|| BitNode-10: Digital Carbon || * Each level of this grants a Duplicate Sleeve. |
|
||||
|| || * Allows the player to access the `Sleeve API <https://github.com/bitburner-official/bitburner-src/blob/dev/markdown/bitburner.sleeve.md>`_ in other BitNodes. |
|
||||
|| || * Grants the player access to the VitaLife secret laboratory in other BitNodes. Also grants access to the Grafting API. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|| BitNode-11: The Big Crash || * Company favor increases both the player's salary and reputation gain at that |
|
||||
|| || company by 1% per favor (rather than just the reputation gain). |
|
||||
|| || * Increases the player's company salary and reputation gain multipliers by |
|
||||
|| || 32%/48%/56%. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|| BitNode-12: The Recursion || * There is no maximum level for this Source-File. |
|
||||
|| || * Let the player start with Neuroflux Governor equal to the level of this |
|
||||
|| || Source-File. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|| BitNode-13: They're lunatics || * This Source-File lets the Church of the Machine God appear in other BitNodes. |
|
||||
|| || * Each level of this Source-File increases the size of Stanek's Gift. |
|
||||
|| || |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| BitNode-1: Source Genesis | * Let the player start with 32 GB of RAM on the home computer. |
|
||||
| | * Increases all of the player's multipliers by 16%/24%/28%. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| BitNode-2: Rise of the Underworld | * Let the player create Gangs in other BitNodes (although some BitNodes will disable this mechanic). |
|
||||
| | * Increases the player's crime success rate, crime money, and charisma multipliers by 24%/36%/42%. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| BitNode-3: Corporatocracy | * Let the player create Corporations in other BitNodes (although some BitNodes will disable this mechanic). |
|
||||
| | * Increases the player's charisma and company salary multipliers by 8%/12%/14%. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| BitNode-4: The Singularity | * Let the player access and use Netscript Singularity Functions in other BitNodes. |
|
||||
| | * Each level of this Source-File reduces the RAM cost of singularity functions. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| BitNode-5: Artificial Intelligence | * Unlocks :ref:`gameplay_intelligence`. |
|
||||
| | * Unlocks :js:func:`getBitNodeMultipliers` and grants permanent access to Formulas.exe. |
|
||||
| | * Increases all of the player's hacking-related multipliers by 8%/12%/14%. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| BitNode-6: Bladeburners | * Unlocks the Bladeburner feature in other BitNodes. |
|
||||
| | * Increases all of the player's level and experience gain rate multipliers for combat stats by 8%/12%/14%. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| BitNode-7: Bladeburners 2079 | * Allows the player to access the `Bladeburner API <https://github.com/bitburner-official/bitburner-src/blob/dev/markdown/bitburner.bladeburner.md>`_ in other BitNodes. |
|
||||
| | * Increases all of the player's Bladeburner multipliers by 8%/12%/14%. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| BitNode-8: Ghost of Wall Street | * Increases the player's hacking growth multiplier by 12%/18%/21%. |
|
||||
| | * Level 1 grants permanent access to :ref:`WSE <gameplay_stock_market>` and the `TIX <https://github.com/bitburner-official/bitburner-src/blob/dev/markdown/bitburner.tix.md>`_ API. |
|
||||
| | * Level 2 grants permanent access to shorting stocks. |
|
||||
| | * Level 3 grants permanent access to use limit/stop orders. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| BitNode-9: Hacktocracy | * Level 1 permanently unlocks the Hacknet Server in other BitNodes. |
|
||||
| | * Level 2 lets the player start with 128 GB of RAM on the home computer. |
|
||||
| | * Level 3 grants a highly-upgraded Hacknet Server when entering a new BitNode (it will be lost after installing augments). |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| BitNode-10: Digital Carbon | * Each level of this grants a Duplicate Sleeve. |
|
||||
| | * Allows the player to access the `Sleeve API <https://github.com/bitburner-official/bitburner-src/blob/dev/markdown/bitburner.sleeve.md>`_ in other BitNodes. |
|
||||
| | * Grants the player access to the VitaLife secret laboratory in other BitNodes. Also grants access to the Grafting API. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| BitNode-11: The Big Crash | * Company favor increases both the player's salary and reputation gain at that company by 1% per favor (rather than just the reputation gain). |
|
||||
| | * Increases the player's company salary and reputation gain multipliers by 32%/48%/56%. |
|
||||
| | * This Source-File reduces the price increase for every aug bought by 4%/5%/7%. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| BitNode-12: The Recursion | * There is no maximum level for this Source-File. |
|
||||
| | * Let the player start with Neuroflux Governor equal to the level of this Source-File. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| BitNode-13: They're lunatics | * This Source-File lets the Church of the Machine God appear in other BitNodes. |
|
||||
| | * Each level of this Source-File increases the size of Stanek's Gift. |
|
||||
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
@ -59,6 +59,7 @@ Here is everything you will KEEP when you install an Augmentation:
|
||||
* Scripts on your home computer
|
||||
* RAM/Core Upgrades on your home computer
|
||||
* World Stock Exchange account and TIX API Access
|
||||
* Previously installed Augmentations
|
||||
|
||||
.. _gameplay_augmentations_purchasingmultiple:
|
||||
|
||||
|
@ -11,3 +11,7 @@ While working for a company, you can click "Do something else simultaneously" to
|
||||
to do things while you continue to work in the background. There is a 20% penalty to the
|
||||
related gains. Clicking the "Focus" button under the overview will return you to the
|
||||
current work.
|
||||
|
||||
If you've been hired to do a job you can click that "Apply for X Job" button again to get a
|
||||
promotion if you meet the requirements. You can see the requirements by hovering your cursor
|
||||
over the button. Higher positions give increased rewards.
|
@ -24,7 +24,7 @@ Crimes are not always successful. Your rate of success is determined by your
|
||||
stats (and Augmentation multipliers) and can be seen on the crime-selection
|
||||
page. If you are unsuccessful at committing a crime you will gain EXP,
|
||||
but you will not earn money. If you are successful at committing the crime
|
||||
you will gain extra EXP (double of what an unsuccessful attempt would give)
|
||||
you will gain extra EXP (4x of what an unsuccessful attempt would give)
|
||||
and earn money.
|
||||
|
||||
Harder crimes are typically more profitable, and also give more EXP.
|
||||
|
@ -207,18 +207,18 @@ List of Factions and their Requirements
|
||||
.. raw:: html
|
||||
|
||||
</details>
|
||||
<details><summary><a>Endgame Factions</a></summary>
|
||||
<details><summary><a>Midgame Factions</a></summary>
|
||||
|
||||
.. _gameplay_factions::
|
||||
|
||||
+---------------------+----------------+-----------------------------------------+-------------------------------+
|
||||
| Endgame | Faction Name | Requirements | Joining this Faction prevents |
|
||||
| Midgame | Faction Name | Requirements | Joining this Faction prevents |
|
||||
| Factions | | | you from joining: |
|
||||
+ +----------------+-----------------------------------------+-------------------------------+
|
||||
| | The Covenant | * 20 Augmentations | |
|
||||
| | | * $75b | |
|
||||
| | | * Hacking Level of 850 | |
|
||||
| | | * All Combat Stats of 850 | |
|
||||
| | | * or All Combat Stats of 850 | |
|
||||
+ +----------------+-----------------------------------------+-------------------------------+
|
||||
| | Daedalus | * 30 Augmentations | |
|
||||
| | | * $100b | |
|
||||
@ -230,6 +230,26 @@ List of Factions and their Requirements
|
||||
| | | * Hacking Level of 1500 | |
|
||||
| | | * All Combat Stats of 1200 | |
|
||||
+---------------------+----------------+-----------------------------------------+-------------------------------+
|
||||
.. raw:: html
|
||||
|
||||
</details>
|
||||
<details><summary><a>Endgame Factions</a></summary>
|
||||
|
||||
.. _gameplay_factions::
|
||||
|
||||
+---------------------+----------------+--------------------------------------------------------------+-------------------------------+
|
||||
| Endgame | Faction Name | Requirements | Joining this Faction prevents |
|
||||
| Factions | | | you from joining: |
|
||||
+ +----------------+--------------------------------------------------------------+-------------------------------+
|
||||
| | Bladeburners | * Join Bladeburner Division | |
|
||||
| | | * Have 25 Rank | |
|
||||
| | | * Be in BitNode 6 or 7 | |
|
||||
| | | * or have Source-File 6 or 7 | |
|
||||
+ +----------------+--------------------------------------------------------------+-------------------------------+
|
||||
| | Church of the | * Have not installed any augmentations in the current BitNode| |
|
||||
| | Machine God | * Be in BitNode 13 | |
|
||||
| | | * or have Source-File 13 | |
|
||||
+---------------------+----------------+--------------------------------------------------------------+-------------------------------+
|
||||
.. raw:: html
|
||||
|
||||
</details><br>
|
||||
|
@ -33,11 +33,11 @@ infiltration will immediately end.
|
||||
|
||||
** Slash when his guard is down! **
|
||||
|
||||
Press space when the guard is attacking you.
|
||||
There's 3 phase
|
||||
Press space when the guard is preparing to attack you.
|
||||
There's 3 phases
|
||||
The first is guarding, where attacking back will result in failure.
|
||||
The 2nd is preparing, this informs you that in 250ms there will be an opening window to attack.
|
||||
The 3rd is attack, during this phase you can press space to slash and kill the enemy.
|
||||
The 2nd is preparing, where attacking will result in a victory.
|
||||
The 3rd is attack, where the guard will attack you resulting in failure.
|
||||
|
||||
** Close the brackets **
|
||||
|
||||
|
@ -78,11 +78,11 @@ with scripts:
|
||||
Prints the logs of the script specified by the name and arguments to
|
||||
Terminal. Arguments should be separated by a space. Remember that scripts
|
||||
are uniquely identified by their arguments as well as their name. For
|
||||
example, if you ran a script `foo.script` with the argument `foodnstuff`
|
||||
example, if you ran a script `foo.hs` with the argument `foodnstuff`
|
||||
then in order to 'check' it you must also add the `foodnstuff` argument
|
||||
to the check command::
|
||||
|
||||
$ check foo.script foodnstuff
|
||||
$ check foo.js foodnstuff
|
||||
|
||||
**free**
|
||||
|
||||
@ -93,11 +93,11 @@ Shows the current server's RAM usage and availability
|
||||
Stops a script that is running with the specified script name and
|
||||
arguments. Arguments should be separated by a space. Remember that
|
||||
scripts are uniquely identified by their arguments as well as
|
||||
their name. For example, if you ran a script `foo.script` with
|
||||
the argument 1 and 2, then just typing "`kill foo.script`" will
|
||||
their name. For example, if you ran a script `foo.js` with
|
||||
the argument 1 and 2, then just typing "`kill foo.js`" will
|
||||
not work. You have to use::
|
||||
|
||||
$ kill foo.script 1 2
|
||||
$ kill foo.js 1 2
|
||||
|
||||
**mem [script] [-t] [n]**
|
||||
|
||||
@ -125,26 +125,30 @@ with no arguments.
|
||||
|
||||
Examples:
|
||||
|
||||
Run 'foo.script' single-threaded with no arguments::
|
||||
Run 'foo.js' single-threaded with no arguments::
|
||||
|
||||
$ run foo.script
|
||||
$ run foo.js
|
||||
|
||||
Run 'foo.script' with 10 threads and no arguments::
|
||||
Run 'foo.js' with 10 threads and no arguments::
|
||||
|
||||
$ run foo.script -t 10
|
||||
$ run foo.js -t 10
|
||||
|
||||
Run 'foo.script' single-threaded with three arguments: [foodnstuff, sigma-cosmetics, 10]::
|
||||
Run 'foo.js' single-threaded with three arguments: [foodnstuff, sigma-cosmetics, 10]::
|
||||
|
||||
$ run foo.script foodnstuff sigma-cosmetics 10
|
||||
$ run foo.js foodnstuff sigma-cosmetics 10
|
||||
|
||||
Run 'foo.script' with 50 threads and a single argument: [foodnstuff]::
|
||||
Run 'foo.js' with 50 threads and a single argument: [foodnstuff]::
|
||||
|
||||
$ run foo.script -t 50 foodnstuff
|
||||
$ run foo.js -t 50 foodnstuff
|
||||
|
||||
|
||||
**tail [script] [args...]**
|
||||
|
||||
Displays the logs of the script specified by the name and arguments. Note that scripts are uniquely identified by their arguments as well as their name. For example, if you ran a script 'foo.script' with the argument 'foodnstuff' then in order to 'tail' it you must also add the 'foodnstuff' argument to the tail command as so: tail foo.script foodnstuff
|
||||
Displays the logs of the script specified by the name and arguments. Note that scripts
|
||||
are uniquely identified by their arguments as well as their name. For example, if you
|
||||
ran a script 'foo.js' with the argument 'foodnstuff' then in order to 'tail' it you
|
||||
must also add the 'foodnstuff' argument to the tail command as so: tail foo.js
|
||||
foodnstuff
|
||||
|
||||
**top**
|
||||
|
||||
|
@ -8,8 +8,11 @@ game are connected to each other to form a large, global network.
|
||||
To learn about how to navigate this network and connect to other
|
||||
servers, see the :ref:`Terminal` page.
|
||||
|
||||
Server RAM
|
||||
^^^^^^^^^^
|
||||
Server Statistics
|
||||
^^^^^^^^^^^^^^^^^
|
||||
Each server has it's own statistics, such as RAM, required hacking level and number of
|
||||
ports required to successfully NUKE it.
|
||||
|
||||
Perhaps the most important property of a server to make note of is its RAM,
|
||||
which refers to how much memory is available on that machine. RAM is
|
||||
important because it is required to run Scripts. More RAM allows
|
||||
@ -19,6 +22,9 @@ a script with :ref:`more threads <gameplay_scripts_multithreadingscripts>`.
|
||||
The `free`, `scan-analyze`, and `analyze` Terminal commands
|
||||
can be used to check how much RAM a server has.
|
||||
|
||||
Some servers have some randomized statistics, such as RAM, max Money or
|
||||
required hacking level. These statistics are randomly genererated from a range of values.
|
||||
|
||||
Identifying Servers
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
A server is identified by its hostname.
|
||||
@ -64,3 +70,10 @@ and exp. See the :ref:`gameplay_hacking` page for more details.
|
||||
|
||||
Different servers have different levels of security, but also offer
|
||||
different rewards when being hacked.
|
||||
|
||||
Server Connections
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
The servers are in a randomly organized tree-structure. The distance from
|
||||
the home computer to each server is fixed, but the exact route to them is
|
||||
randomized when you install :ref:`gameplay_augmentations`. In general the
|
||||
further away from home computer a server is the higher it's statistics are.
|
@ -33,7 +33,7 @@ In order to create a directory, simply name a file using a full absolute Linux-s
|
||||
This will automatically create a "directory" called :code:`scripts`. This will also work
|
||||
for subdirectories::
|
||||
|
||||
/scripts/hacking/helpers/myHelperScripts.script
|
||||
/scripts/hacking/helpers/myHelperScripts.js
|
||||
|
||||
Files in the root directory do not need to begin with a forward slash::
|
||||
|
||||
@ -72,9 +72,9 @@ Note that in order to reference a file, :ref:`netscript` functions require the
|
||||
|
||||
.. code:: javascript
|
||||
|
||||
run("/scripts/hacking/helpers.myHelperScripts.script");
|
||||
rm("/logs/myHackingLogs.txt");
|
||||
rm("thisIsAFileInTheRootDirectory.txt");
|
||||
ns.run("/scripts/hacking/helpers.myHelperScripts.js");
|
||||
ns.rm("/logs/myHackingLogs.txt");
|
||||
ns.rm("thisIsAFileInTheRootDirectory.txt");
|
||||
|
||||
.. note:: A full file path **must** begin with a forward slash (/) if that file
|
||||
is not in the root directory.
|
||||
@ -150,13 +150,17 @@ This can pass faction tests or give bonsues such as discounts from companies.
|
||||
buy
|
||||
^^^
|
||||
|
||||
$ buy [-l/program]
|
||||
$ buy [-l/-a/program]
|
||||
|
||||
Purchase a program through the Dark Web. Requires a TOR Router to use.
|
||||
|
||||
If this command is ran with the '-l' flag, it will display a list of all programs
|
||||
that can be purchased through the Dark Web, as well as their costs.
|
||||
|
||||
If this command is ran with the '-a' flag, it will attempt to buy all programs
|
||||
that can be purchased through the Dark Web and if the player can't afford all of them
|
||||
none will be bought.
|
||||
|
||||
Otherwise, the name of the program must be passed in as a parameter. This name
|
||||
is NOT case-sensitive::
|
||||
|
||||
@ -205,11 +209,11 @@ Each argument must be separated by a space.
|
||||
**Remember that a running script is uniquely identified both by its name and the arguments that are used to start it**. So,
|
||||
if a script was ran with the following arguments::
|
||||
|
||||
$ run foo.script 1 2 foodnstuff
|
||||
$ run foo.js 1 2 foodnstuff
|
||||
|
||||
Then to run the 'check' command on this script you would have to pass the same arguments in::
|
||||
|
||||
$ check foo.script 1 2 foodnstuff
|
||||
$ check foo.js 1 2 foodnstuff
|
||||
|
||||
clear/cls
|
||||
^^^^^^^^^
|
||||
@ -275,7 +279,7 @@ hack
|
||||
|
||||
Attempt to hack the current server. Requires root access in order to be run.
|
||||
|
||||
Related: Hacking Mechanics (TODO Add link here when page gets made)
|
||||
Related: Hacking Mechanics :ref:`hacking`
|
||||
|
||||
help
|
||||
^^^^
|
||||
@ -302,29 +306,27 @@ hostname
|
||||
|
||||
Prints the hostname of the server you are currently connected to.
|
||||
|
||||
ifconfig
|
||||
^^^^^^^^
|
||||
|
||||
Prints the IP address of the server you are currently connected to.
|
||||
|
||||
kill
|
||||
^^^^
|
||||
|
||||
$ kill [script name] [args...]
|
||||
$ kill [pid]
|
||||
|
||||
Kill the script specified by the script filename and arguments OR by its PID.
|
||||
Kill the script specified by the script filename and arguments OR by its PID. If
|
||||
filename and arguments are used the kill is server-specific, so if you're connected
|
||||
to home and want to kill a script running on n00dles, you have to either use it's PID
|
||||
or :code:`connect` to n00dles first and then use the the kill command.
|
||||
|
||||
If you are killing the script using its filename and arguments, then each argument
|
||||
must be separated by a space. Remember that a running script is uniquely identified
|
||||
by both its name and the arguments that are used to start it. So, if a script
|
||||
was ran with the following arguments::
|
||||
|
||||
$ run foo.script 50e3 sigma-cosmetics
|
||||
$ run foo.js 50e3 sigma-cosmetics
|
||||
|
||||
Then to kill this script the same arguments would have to be used::
|
||||
|
||||
$ kill foo.script 50e3 sigma-cosmetics
|
||||
$ kill foo.js 50e3 sigma-cosmetics
|
||||
|
||||
If you are killing the script using its PID, then the PID argument must be numeric.
|
||||
|
||||
@ -362,7 +364,7 @@ Examples::
|
||||
// List files/directories with the '.js' extension in the root directory
|
||||
$ ls / -l --grep .js
|
||||
|
||||
// List files/directories with the word 'purchase' in the name, in the :code:`scripts` directory
|
||||
// List files/directories with the word 'purchase' in the name, in the 'scripts' directory
|
||||
$ ls scripts -l --grep purchase
|
||||
|
||||
|
||||
@ -384,12 +386,12 @@ a script with multiple threads using the '-t' flag. If the '-t' flag is
|
||||
specified, then an argument for the number of threads must be passed in
|
||||
afterwards. Examples::
|
||||
|
||||
$ mem foo.script
|
||||
$ mem foo.script -t 50
|
||||
$ mem foo.js
|
||||
$ mem foo.js -t 50
|
||||
|
||||
The first example above will print the amount of RAM needed to run 'foo.script'
|
||||
The first example above will print the amount of RAM needed to run 'foo.js'
|
||||
with a single thread. The second example above will print the amount of RAM needed
|
||||
to run 'foo.script' with 50 threads.
|
||||
to run 'foo.js' with 50 threads.
|
||||
|
||||
.. _mv_terminal_command:
|
||||
|
||||
@ -467,9 +469,9 @@ Run a program::
|
||||
|
||||
$ run BruteSSH.exe
|
||||
|
||||
Run *foo.script* with 50 threads and the arguments [1e3, 0.5, foodnstuff]::
|
||||
Run *foo.js* with 50 threads and the arguments [1e3, 0.5, foodnstuff]::
|
||||
|
||||
$ run foo.script -t 50 1e3 0.5 foodnstuff
|
||||
$ run foo.js -t 50 1e3 0.5 foodnstuff
|
||||
|
||||
Run a Coding Contract::
|
||||
|
||||
@ -500,7 +502,26 @@ execute 'scan-analyze' with a depth up to 5 and 10, respectively.
|
||||
|
||||
The information 'scan-analyze' displays about each server includes whether or
|
||||
not you have root access to it, its required hacking level, the number of open
|
||||
ports required to run NUKE.exe on it, and how much RAM it has.
|
||||
ports required to run NUKE.exe on it, and how much RAM it has. When used the
|
||||
information is structured like:
|
||||
|
||||
n00dles
|
||||
--Root Access: YES, Required hacking skill: 1
|
||||
--Number of open ports required to NUKE: 0
|
||||
--RAM: 4.00GB
|
||||
|
||||
----zer0
|
||||
------Root Access: NO, Required hacking skill: 75
|
||||
------Number of open ports required to NUKE: 1
|
||||
------RAM: 32.00GB
|
||||
|
||||
foodnstuff
|
||||
--Root Access: NO, Required hacking skill: 1
|
||||
--Number of open ports required to NUKE: 0
|
||||
--RAM: 16.00GB
|
||||
|
||||
In this case :code:`n00dles` and :code:`foodnstuff` are connected to the current server
|
||||
and :code:`zer0` is connected to :code:`n00dles`.
|
||||
|
||||
.. _scp_terminal_command:
|
||||
|
||||
@ -529,11 +550,11 @@ Each argument must be separated by a space. Remember that a running script is
|
||||
uniquely identified by both its name and the arguments that were used to run
|
||||
it. So, if a script was ran with the following arguments::
|
||||
|
||||
$ run foo.script 10 50000
|
||||
$ run foo.js 10 50000
|
||||
|
||||
Then in order to check its logs with 'tail' the same arguments must be used::
|
||||
|
||||
$ tail foo.script 10 50000
|
||||
$ tail foo.js 10 50000
|
||||
|
||||
top
|
||||
^^^
|
||||
@ -590,26 +611,28 @@ There are two main points:
|
||||
2. Anything that can represent a number is automatically cast to a number, unless its
|
||||
surrounded by quotation marks.
|
||||
|
||||
Here's an example to show how these rules work. Consider the following script `argType.script`::
|
||||
|
||||
tprint("Number of args: " + args.length);
|
||||
for (var i = 0; i < args.length; ++i) {
|
||||
tprint(typeof args[i]);
|
||||
Here's an example to show how these rules work. Consider the following script `argType.js`::
|
||||
|
||||
export async function main(ns) {
|
||||
ns.tprint("Number of args: " + args.length);
|
||||
for (var i = 0; i < ns.args.length; ++i) {
|
||||
ns.tprint(typeof ns.args[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Then if we run the following terminal command::
|
||||
|
||||
$ run argType.script 123 1e3 "5" "this is a single argument"
|
||||
$ run argType.js 123 1e3 "5" "this is a single argument"
|
||||
|
||||
We'll see the following in the Terminal::
|
||||
|
||||
Running script with 1 thread(s) and args: [123, 1000, "5", "this is a single argument"].
|
||||
May take a few seconds to start up the process...
|
||||
argType.script: Number of args: 4
|
||||
argType.script: number
|
||||
argType.script: number
|
||||
argType.script: string
|
||||
argType.script: string
|
||||
argType.js: Number of args: 4
|
||||
argType.js: number
|
||||
argType.js: number
|
||||
argType.js: string
|
||||
argType.js: string
|
||||
|
||||
Chaining Commands
|
||||
-----------------
|
||||
@ -618,4 +641,4 @@ with a semicolon (;).
|
||||
|
||||
Example::
|
||||
|
||||
$ run foo.script; tail foo.script
|
||||
$ run foo.js; tail foo.js
|
||||
|
@ -10,3 +10,7 @@ In Bitburner, the world consists of six different cities:
|
||||
* New Tokyo
|
||||
* Chongqing
|
||||
* Volhaven
|
||||
|
||||
Each city has it's own map and :ref:`faction`. Each city also
|
||||
offers different services, such as gyms, universities, hardware
|
||||
stores and places of work.
|
@ -8,7 +8,7 @@ If your game is frozen or stuck in any way, then the most likely culprit is an
|
||||
infinitely running loop in :ref:`netscriptjs`. To get past the freezing, run the game with
|
||||
`?noScripts` in the URL:
|
||||
|
||||
`https://danielyxie.github.io/bitburner/?noScripts <https://danielyxie.github.io/bitburner/?noScripts>`_
|
||||
`https://bitburner-official.github.io/bitburner/?noScripts <https://bitburner-official.github.io/bitburner/?noScripts>`_
|
||||
|
||||
Then, to fix your script, make sure you have a sleep or any other timed function like `hack()` or
|
||||
`grow()` in any infinite loops::
|
||||
|
@ -34,7 +34,7 @@ to do this:
|
||||
|
||||
1. You can go to the Terminal and enter::
|
||||
|
||||
$ kill n00dles.script
|
||||
$ kill n00dles.js
|
||||
|
||||
2. You can go to the :code:`Active Scripts` page (|Keyboard shortcut| Alt + s) and
|
||||
press the "Kill Script" button for :code:`n00dles.js`.
|
||||
@ -413,6 +413,7 @@ Create the script by going to |Terminal| and typing::
|
||||
Paste the following code into the script editor:
|
||||
|
||||
.. code:: javascript
|
||||
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
// How much RAM each purchased server will have. In this case, it'll
|
||||
@ -433,8 +434,8 @@ Paste the following code into the script editor:
|
||||
// 3. Run our hacking script on the newly-purchased server with 3 threads
|
||||
// 4. Increment our iterator to indicate that we've bought a new server
|
||||
let hostname = ns.purchaseServer("pserv-" + i, ram);
|
||||
ns.scp("early-hack-template.script", hostname);
|
||||
ns.exec("early-hack-template.script", hostname, 3);
|
||||
ns.scp("early-hack-template.js", hostname);
|
||||
ns.exec("early-hack-template.js", hostname, 3);
|
||||
++i;
|
||||
}
|
||||
//Make the script wait for a second before looping again.
|
||||
@ -838,9 +839,9 @@ startup script. Feel free to adjust it to your liking.
|
||||
for (let i = 0; i < servers0Port.length; ++i) {
|
||||
const serv = servers0Port[i];
|
||||
|
||||
ns.scp("early-hack-template.script", serv);
|
||||
ns.scp("early-hack-template.js", serv);
|
||||
ns.nuke(serv);
|
||||
ns.exec("early-hack-template.script", serv, 6);
|
||||
ns.exec("early-hack-template.js", serv, 6);
|
||||
}
|
||||
|
||||
// Wait until we acquire the "BruteSSH.exe" program
|
||||
@ -854,10 +855,10 @@ startup script. Feel free to adjust it to your liking.
|
||||
for (let i = 0; i < servers1Port.length; ++i) {
|
||||
const serv = servers1Port[i];
|
||||
|
||||
ns.scp("early-hack-template.script", serv);
|
||||
ns.scp("early-hack-template.js", serv);
|
||||
ns.brutessh(serv);
|
||||
ns.nuke(serv);
|
||||
ns.exec("early-hack-template.script", serv, 12);
|
||||
ns.exec("early-hack-template.sj", serv, 12);
|
||||
}
|
||||
}
|
||||
Random Tips
|
||||
|
@ -7,7 +7,7 @@ Welcome to Bitburner's documentation!
|
||||
=====================================
|
||||
Bitburner is a programming-based `incremental game <https://en.wikipedia.org/wiki/Incremental_game>`_
|
||||
that revolves around hacking and cyberpunk themes. The game is currently in the
|
||||
early beta stage of development. It `can be played here <https://danielyxie.github.io/bitburner/>`_.
|
||||
early beta stage of development. It `can be played here <https://bitburner-official.github.io/bitburner/>`_.
|
||||
|
||||
What is Bitburner?
|
||||
------------------
|
||||
@ -33,7 +33,6 @@ secrets that you've been searching for.
|
||||
v1.0.0 script migration guide <v1.0.0_migration.rst>
|
||||
v2.0.0 script migration guide <v2.0.0_migration.rst>
|
||||
404 <404.rst>
|
||||
Donate <https://paypal.me/danielyxie>
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
@ -14,4 +14,4 @@ brutessh() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
brutessh("foodnstuff");
|
||||
ns.brutessh("foodnstuff");
|
||||
|
@ -12,3 +12,10 @@ deleteServer() Netscript Function
|
||||
The ``hostname`` argument can be any data type, but it will be converted to
|
||||
a string. Whitespace is automatically removed from the string. This function
|
||||
will not delete a server that still has scripts running on it.
|
||||
|
||||
Examples:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
ns.killall("dummyServer");
|
||||
ns.deleteServer("dummyServer"); //returns: true if purhcased server 'dummyServer'existed
|
||||
|
@ -24,17 +24,17 @@ exec() Netscript Function
|
||||
|
||||
The simplest way to use the :doc:`exec<exec>` command is to call it with
|
||||
just the script name and the target server. The following example will try
|
||||
to run ``generic-hack.script`` on the ``foodnstuff`` server::
|
||||
to run ``generic-hack.js`` on the ``foodnstuff`` server::
|
||||
|
||||
exec("generic-hack.script", "foodnstuff");
|
||||
ns.exec("generic-hack.js", "foodnstuff");
|
||||
|
||||
The following example will try to run the script ``generic-hack.script`` on
|
||||
The following example will try to run the script ``generic-hack.js`` on
|
||||
the ``joesguns`` server with 10 threads::
|
||||
|
||||
exec("generic-hack.script", "joesguns", 10);
|
||||
ns.exec("generic-hack.js", "joesguns", 10);
|
||||
|
||||
This last example will try to run the script ``foo.script`` on the
|
||||
This last example will try to run the script ``foo.js`` on the
|
||||
``foodnstuff`` server with 5 threads. It will also pass the number 1 and the
|
||||
string "test" in as arguments to the script::
|
||||
|
||||
exec("foo.script", "foodnstuff", 5, 1, "test");
|
||||
ns.exec("foo.js", "foodnstuff", 5, 1, "test");
|
||||
|
@ -22,8 +22,8 @@ fileExists() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
fileExists("foo.script", "foodnstuff"); // returns: false
|
||||
fileExists("ftpcrack.exe"); // returns: true
|
||||
ns.fileExists("foo.js", "foodnstuff"); // returns: false
|
||||
ns.fileExists("ftpcrack.exe"); // returns: true
|
||||
|
||||
The first example above will return true if the script named ``foo.script`` exists on the ``foodnstuff`` server, and false otherwise.
|
||||
The first example above will return true if the script named ``foo.js`` exists on the ``foodnstuff`` server, and false otherwise.
|
||||
The second example above will return true if the current server contains the ``FTPCrack.exe`` program, and false otherwise.
|
||||
|
@ -14,4 +14,4 @@ ftpcrack() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
ftpcrack("foodnstuff");
|
||||
ns.ftpcrack("foodnstuff");
|
||||
|
@ -10,4 +10,4 @@ getHackingLevel() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
getHackingLevel(); // returns: 124
|
||||
ns.getHackingLevel(); // returns: 124
|
||||
|
@ -21,6 +21,6 @@ getHackingMultipliers() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
mults = getHackingMultipliers();
|
||||
print(mults.chance);
|
||||
print(mults.growth);
|
||||
const mults = ns.getHackingMultipliers();
|
||||
ns.print(mults.chance);
|
||||
ns.print(mults.growth);
|
||||
|
@ -22,6 +22,6 @@ getHacknetMultipliers() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
mults = getHacknetMultipliers();
|
||||
print(mults.production);
|
||||
print(mults.purchaseCost);
|
||||
const mults = ns.getHacknetMultipliers();
|
||||
ns.print(mults.production);
|
||||
ns.print(mults.purchaseCost);
|
||||
|
@ -5,11 +5,13 @@ getPurchasedServerCost() Netscript Function
|
||||
|
||||
:RAM cost: 0.25 GB
|
||||
|
||||
:param number ram: Amount of RAM of a potential purchased server. Must be a power of 2 (2, 4, 8, 16, etc.). Maximum value of 1048576 (2^20)
|
||||
:param number ram: Amount of RAM of a potential purchased server. Must be a power of 2 (2, 4, 8, 16, etc.). Maximum value of :doc:`getPurchasedServerMaxRam<getPurchasedServerMaxRam>`
|
||||
:returns: Cost to purchase a server with the specified amount of ``ram``.
|
||||
|
||||
Giving any non-power-of-2 as an argument results in the function returning `Infinity`
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
getPurchasedServerCost(8192); // returns: 450560000
|
||||
ns.getPurchasedServerCost(8192); // returns: 450560000
|
||||
|
@ -10,4 +10,4 @@ getPurchasedServerLimit() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
getPurchasedServerLimit() // returns: 25
|
||||
ns.getPurchasedServerLimit() // returns: 25
|
||||
|
@ -10,4 +10,4 @@ getPurchasedServerMaxRam() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
getPurchasedServerMaxRam(); // returns: 1048576
|
||||
ns.getPurchasedServerMaxRam(); // returns: 1048576
|
||||
|
@ -0,0 +1,18 @@
|
||||
getPurchasedServerUpgradeCost() Netscript Function
|
||||
===========================================
|
||||
|
||||
.. js:function:: getPurchasedServerUpgradeCost(hostname, ram)
|
||||
|
||||
:RAM cost: 0.25 GB
|
||||
|
||||
:param string hostname: Hostname of target purchased server.
|
||||
:param number ram: Target amount of RAM for purchased server. Must be a power of 2 (2, 4, 8, 16, etc.). Maximum value of :doc:`getPurchasedServerMaxRam<getPurchasedServerMaxRam>`
|
||||
:returns: Cost to purchase a server with the specified amount of ``ram``.
|
||||
|
||||
Giving any non-power-of-2 as an argument results in the function returning `-1`
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: javascript
|
||||
ns.purchaseServer("smallServer",2) //costs 110000
|
||||
ns.getPurchasedServerUpgradeCost("smallServer",8); // returns: 330000
|
@ -10,4 +10,4 @@ getPurchasedServers() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
getPurchasedServers(); // returns: ['grow-server-0', 'grow-server-1', 'weaken-server-0']
|
||||
ns.getPurchasedServers(); // returns: ['grow-server-0', 'grow-server-1', 'weaken-server-0']
|
||||
|
@ -13,4 +13,4 @@ getScriptRam() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
getScriptRam("grow.script"); // returns: 1.75
|
||||
ns.getScriptRam("grow.js"); // returns: 1.75
|
||||
|
@ -11,4 +11,4 @@ getServerMaxMoney() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
getServerMaxMoney('foodnstuff'); // returns: 50000000
|
||||
ns.getServerMaxMoney('foodnstuff'); // returns: 50000000
|
||||
|
@ -11,5 +11,5 @@ getServerMaxRam() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
maxRam = getServerMaxRam("helios"); // returns: 16
|
||||
print("helios has "+maxRam + "GB");
|
||||
const maxRam = ns.getServerMaxRam("helios"); // returns: 16
|
||||
ns.print("helios has "+maxRam + "GB");
|
||||
|
@ -11,4 +11,4 @@ getServerMinSecurityLevel() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
getServerMinSecurityLevel('foodnstuff'); // returns: 3
|
||||
ns.getServerMinSecurityLevel('foodnstuff'); // returns: 3
|
||||
|
@ -15,5 +15,5 @@ getServerMoneyAvailable() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
getServerMoneyAvailable("foodnstuff"); // returns: 120000
|
||||
getServerMoneyAvailable("home"); // returns: 1000
|
||||
ns.getServerMoneyAvailable("foodnstuff"); // returns: 120000
|
||||
ns.getServerMoneyAvailable("home"); // returns: 1000
|
||||
|
@ -12,4 +12,4 @@ getServerNumPortsRequired() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
getServerNumPortsRequired("unitalife"); // returns: 4
|
||||
ns.getServerNumPortsRequired("unitalife"); // returns: 4
|
||||
|
@ -11,4 +11,4 @@ getServerRequiredHackingLevel() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
getServerRequiredHackingLevel("foodnstuff"); // returns: 5
|
||||
ns.getServerRequiredHackingLevel("foodnstuff"); // returns: 5
|
||||
|
@ -11,4 +11,4 @@ getServerSecurityLevel() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
getServerSecurityLevel("foodnstuff"); // returns: 3.45
|
||||
ns.getServerSecurityLevel("foodnstuff"); // returns: 3.45
|
||||
|
@ -11,5 +11,5 @@ getServerUsedRam() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
usedRam = getServerUsedRam("harakiri-sushi"); // returns: 5.6
|
||||
print("harakiri-sushi uses "+usedRam + "GB");
|
||||
const usedRam = ns.getServerUsedRam("harakiri-sushi"); // returns: 5.6
|
||||
ns.print("harakiri-sushi uses "+ usedRam + "GB"); // prints: "harakiri-sushi uses 5.6GB"
|
||||
|
@ -17,8 +17,8 @@ grow() Netscript Function
|
||||
Increase the amount of money available on a server. The time it takes to
|
||||
execute depends on your hacking level and the target server's security
|
||||
level. When :doc:`grow<grow>` completes, the money available on a target
|
||||
server will be increased by a certain, fixed percentage. This percentage is
|
||||
determined by the target server's growth rate (which varies between servers)
|
||||
server will be increased by the number of threads used and a certain, fixed percentage.
|
||||
The percentage is determined by the target server's growth rate (which varies between servers)
|
||||
and security level. Generally, higher-level servers have higher growth
|
||||
rates.
|
||||
|
||||
@ -34,5 +34,5 @@ grow() Netscript Function
|
||||
.. code-block:: javascript
|
||||
|
||||
while(true) {
|
||||
grow("foodnstuff");
|
||||
await ns.grow("foodnstuff");
|
||||
}
|
||||
|
@ -33,6 +33,6 @@ hack() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
hack("foodnstuff");
|
||||
hack("10.1.2.3");
|
||||
hack("foodnstuff", { threads: 5 }); // Only use 5 threads to hack
|
||||
await ns.hack("foodnstuff");
|
||||
await ns.hack("10.1.2.3");
|
||||
await ns.hack("foodnstuff", { threads: 5 }); // Only use 5 threads to hack
|
||||
|
@ -11,6 +11,12 @@ hasRootAccess() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
if (hasRootAccess("foodnstuff") == false) {
|
||||
nuke("foodnstuff");
|
||||
if (ns.hasRootAccess("foodnstuff") == false) {
|
||||
ns.nuke("foodnstuff");
|
||||
}
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
if (ns.hasRootAccess("foodnstuff")) {
|
||||
ns.exec("foo.js", 1, "foodnstuff");
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ httpworm() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
httpworm("foodnstuff");
|
||||
ns.httpworm("foodnstuff");
|
||||
|
@ -11,4 +11,4 @@ isLogEnabled() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
isLogEnabled('hack'); // returns: true
|
||||
ns.isLogEnabled('hack'); // returns: true
|
||||
|
@ -16,20 +16,20 @@ isRunning() Netscript Function
|
||||
**Examples:**
|
||||
|
||||
In this first example below, the function call will return true if there is
|
||||
a script named ``foo.script`` with no arguments running on the
|
||||
a script named ``foo.js`` with no arguments running on the
|
||||
``foodnstuff`` server, and false otherwise:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
isRunning("foo.script", "foodnstuff");
|
||||
ns.isRunning("foo.js", "foodnstuff");
|
||||
|
||||
In this second example below, the function call will return true if there is
|
||||
a script named ``foo.script`` with no arguments running on the current
|
||||
a script named ``foo.js`` with no arguments running on the current
|
||||
server, and false otherwise:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
isRunning("foo.script", getHostname());
|
||||
ns.isRunning("foo.js", ns.getHostname());
|
||||
|
||||
In this next example below, the function call will return true if there is a
|
||||
script named ``foo.script`` running with the arguments 1, 5, and "test" (in
|
||||
@ -37,7 +37,7 @@ isRunning() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
isRunning("foo.script", "joesguns", 1, 5, "test");
|
||||
ns.isRunning("foo.js", "joesguns", 1, 5, "test");
|
||||
|
||||
|
||||
.. js:function:: isRunning(scriptPid)
|
||||
@ -51,4 +51,4 @@ isRunning() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
isRunning(39);
|
||||
ns.isRunning(39);
|
||||
|
@ -1,42 +1,42 @@
|
||||
kill() Netscript Function
|
||||
=========================
|
||||
|
||||
.. js:function:: kill(script, hostname, [args...])
|
||||
.. js:function:: kill(script, [hostname=current hostname, [args...]])
|
||||
|
||||
:RAM cost: 0.5 GB
|
||||
:param string script: Filename of the script to kill.
|
||||
:param string hostname: Hostname of the server on which to kill the script.
|
||||
:param string hostname: Hostname of the server on which to kill the script.
|
||||
:param args...: Arguments to identify which script to kill.
|
||||
:returns: ``true`` is that script was killed.
|
||||
|
||||
Kills the script on the target server specified by the script's name and
|
||||
arguments. Remember that scripts are uniquely identified by both their name
|
||||
and arguments. For example, if ``foo.script`` is run with the argument 1,
|
||||
then this is not the same as ``foo.script`` run with the argument 2, even
|
||||
and arguments. For example, if ``foo.js`` is run with the argument 1,
|
||||
then this is not the same as ``foo.js`` run with the argument 2, even
|
||||
though they have the same code.
|
||||
|
||||
Examples:
|
||||
|
||||
The following example will try to kill a script named ``foo.script`` on the
|
||||
The following example will try to kill a script named ``foo.js`` on the
|
||||
``foodnstuff`` server that was ran with no arguments:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
kill("foo.script", "foodnstuff");
|
||||
ns.kill("foo.js", "foodnstuff");
|
||||
|
||||
The following will try to kill a script named ``foo.script`` on the current
|
||||
The following will try to kill a script named ``foo.js`` on the current
|
||||
server that was ran with no arguments:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
kill("foo.script", getHostname());
|
||||
ns.kill("foo.js");
|
||||
|
||||
The following will try to kill a script named ``foo.script`` on the current
|
||||
The following will try to kill a script named ``foo.js`` on the current
|
||||
server that was ran with the arguments 1 and "foodnstuff":
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
kill("foo.script", getHostname(), 1, "foodnstuff");
|
||||
ns.kill("foo.js", ns.getHostname(), 1, "foodnstuff");
|
||||
|
||||
.. js:function:: kill(scriptPid)
|
||||
|
||||
@ -53,6 +53,6 @@ kill() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
if (kill(10)) {
|
||||
print("Killed script with PID 10!");
|
||||
if (ns.kill(10)) {
|
||||
ns.print("Killed script with PID 10!");
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
killall() Netscript Function
|
||||
============================
|
||||
|
||||
.. js:function:: killall(hostname)
|
||||
.. js:function:: killall([hostname = current hostname,[safetyguard = true]])
|
||||
|
||||
:RAM cost: 0.5 GB
|
||||
:param string hostname: Hostname of the server on which to kill all scripts.
|
||||
:param boolean safetyguard: Whether the function will safeguard the current script or not.
|
||||
:returns: ``true`` if scripts were killed on target server.
|
||||
|
||||
Kills all running scripts on the specified server.
|
||||
@ -14,4 +15,10 @@ killall() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
killall('foodnstuff'); // returns: true
|
||||
ns.killall('foodnstuff'); // returns: true
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
ns.killall(); // returns: true, kills all scripts on the current server, except the current script
|
||||
ns.killall(); // returns: false, because all no available scripts are running anymore
|
||||
ns.killall(ns.getHostname(),false) // returns: true, but also kills the current script
|
||||
|
@ -12,4 +12,6 @@ ls() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
ls("home"); // returns: ["demo.script", "msg1.txt"]
|
||||
ns.ls("home"); // returns: ["demo.js", "msg1.txt"]
|
||||
ns.ls("home", ".txt"); // returns: ["msg1.txt"]
|
||||
ns.ls("home", ".script"); // returns: []
|
||||
|
@ -7,11 +7,12 @@ nuke() Netscript Function
|
||||
:param string hostname: Hostname of the target server.
|
||||
|
||||
Runs the ``NUKE.exe`` program on the target server. ``NUKE.exe`` must exist
|
||||
on your home computer.
|
||||
on your home computer. Requires the targeted server to have enough ports opened,
|
||||
otherwise will throw an error.
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
nuke("foodnstuff");
|
||||
ns.nuke("foodnstuff");
|
||||
|
@ -12,5 +12,7 @@ print() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
print("Hello world!"); // Prints "Hello world!" in the logs.
|
||||
print({a:5}); // Prints '{"a":5}' in the logs.
|
||||
ns.print("Hello world!"); // Prints "Hello world!" in the logs.
|
||||
ns.print({a:5}); // Prints '{"a":5}' in the logs.
|
||||
const text = "can"
|
||||
ns.print("I "+ text +" use variables :)") // Prints "I can use variables :)"
|
@ -23,9 +23,9 @@ ps() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
processes = ps("home");
|
||||
for (let i = 0; i < processes.length; ++i) {
|
||||
tprint(processes[i].filename + ' ' + processes[i].threads);
|
||||
tprint(processes[i].args);
|
||||
tprint(processes[i].pid);
|
||||
const processes = ns.ps("home");
|
||||
for (const i = 0; i < processes.length; ++i) {
|
||||
ns.tprint(processes[i].filename + ' ' + processes[i].threads);
|
||||
ns.tprint(processes[i].args);
|
||||
ns.tprint(processes[i].pid);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ purchaseServer() Netscript Function
|
||||
2. Maximum value of :doc:`getPurchasedServerMaxRam<getPurchasedServerMaxRam>`
|
||||
:returns: The hostname of the newly purchased server. Empty string on failure.
|
||||
|
||||
Purchased a server with the specified hostname and amount of RAM.
|
||||
Purchases a server with the specified hostname and amount of RAM.
|
||||
|
||||
The ``hostname`` argument can be any data type, but it will be converted to
|
||||
a string and have whitespace removed. Anything that resolves to an empty
|
||||
@ -27,8 +27,8 @@ purchaseServer() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
ram = 64;
|
||||
hn = "pserv-";
|
||||
for (i = 0; i < 5; ++i) {
|
||||
purchaseServer(hn + i, ram);
|
||||
const ram = 64;
|
||||
const name = "pserv-";
|
||||
for (const i = 0; i < 5; ++i) {
|
||||
ns.purchaseServer(name + i, ram);
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ relaysmtp() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
relaysmtp("foodnstuff");
|
||||
ns.relaysmtp("foodnstuff");
|
||||
|
@ -21,23 +21,23 @@ run() Netscript Function
|
||||
less will cause a runtime error.
|
||||
|
||||
The simplest way to use the :doc:`run<run>` command is to call it with just
|
||||
the script name. The following example will run ``foo.script``
|
||||
the script name. The following example will run ``foo.js``
|
||||
single-threaded with no arguments:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
run("foo.script");
|
||||
ns.run("foo.js");
|
||||
|
||||
The following example will run 'foo.script' but with 5 threads instead of
|
||||
The following example will run 'foo.js' but with 5 threads instead of
|
||||
single-threaded:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
run("foo.script", 5);
|
||||
ns.run("foo.js", 5);
|
||||
|
||||
This next example will run ``foo.script`` single-threaded, and will pass the
|
||||
This next example will run ``foo.js`` single-threaded, and will pass the
|
||||
string ``foodnstuff`` into the script as an argument:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
run("foo.script", 1, 'foodnstuff');
|
||||
ns.run("foo.sj", 1, 'foodnstuff');
|
||||
|
@ -12,4 +12,4 @@ scan() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
scan("home"); // returns: ["foodnstuff", "sigma-cosmetics", "joesguns", "hong-fang-tea", "harakiri-sushi", "iron-gym"]
|
||||
ns.scan("home"); // returns: ["foodnstuff", "sigma-cosmetics", "joesguns", "hong-fang-tea", "harakiri-sushi", "iron-gym"]
|
||||
|
@ -23,11 +23,11 @@ scp() Netscript Function
|
||||
.. code-block:: javascript
|
||||
|
||||
//Copies "hack-template.script" from the current server to "foodnstuff"
|
||||
scp("hack-template.script", "foodnstuff"); // returns: true
|
||||
ns.scp("hack-template.script", "foodnstuff"); // returns: true
|
||||
|
||||
//Copies "foo.lit" from the helios server to the "home" computer
|
||||
scp("foo.lit", "home", "helios"); // returns: true
|
||||
ns.scp("foo.lit", "home", "helios"); // returns: true
|
||||
|
||||
//Tries to copy three files from "rothman-uni" to "home" computer
|
||||
files = ["foo1.lit", "foo2.script", "foo3.script"];
|
||||
scp(files, "home", "rothman-uni"); // returns: true
|
||||
const files = ["foo1.lit", "foo2.script", "foo3.script"];
|
||||
ns.scp(files, "home", "rothman-uni"); // returns: true
|
||||
|
@ -15,4 +15,4 @@ scriptKill() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
scriptKill("demo.script", "home"); // returns: true
|
||||
ns.scriptKill("demo.js", "home"); // returns: true
|
||||
|
@ -16,15 +16,15 @@ scriptRunning() Netscript Function
|
||||
Examples:
|
||||
|
||||
The example below will return true if there is any script named
|
||||
``foo.script`` running on the ``foodnstuff`` server, and false otherwise:
|
||||
``foo.js`` running on the ``foodnstuff`` server, and false otherwise:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
scriptRunning("foo.script", "foodnstuff");
|
||||
ns.scriptRunning("foo.js", "foodnstuff");
|
||||
|
||||
The example below will return true if there is any script named
|
||||
``foo.script`` running on the current server, and false otherwise:
|
||||
``foo.js`` running on the current server, and false otherwise:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
scriptRunning("foo.script", getHostname());
|
||||
ns.scriptRunning("foo.js", ns.getHostname());
|
||||
|
@ -11,4 +11,4 @@ serverExists() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
serverExists("foodnstuff"); // returns: true
|
||||
ns.serverExists("foodnstuff"); // returns: true
|
||||
|
@ -12,4 +12,4 @@ sleep() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
sleep(3000); // Will wait 3 seconds.
|
||||
await ns.sleep(3000); // Will wait 3 seconds.
|
||||
|
@ -23,4 +23,4 @@ spawn() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
spawn('foo.script', 10, 'foodnstuff', 90); // "run foo.script foodnstuff 90 -t 10" in 10 seconds.
|
||||
ns.spawn('foo.js', 10, 'foodnstuff', 90); // "run foo.js foodnstuff 90 -t 10" in 10 seconds.
|
||||
|
@ -13,4 +13,4 @@ sqlinject() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
sqlinject("foodnstuff");
|
||||
ns.sqlinject("foodnstuff");
|
||||
|
@ -12,5 +12,5 @@ tprint() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
tprint("Hello world!"); // Prints "Hello world!" to the terminal.
|
||||
tprint({a:5}); // Prints '{"a":5}' to the terminal.
|
||||
ns.tprint("Hello world!"); // Prints "Hello world!" to the terminal.
|
||||
ns.tprint({a:5}); // Prints '{"a":5}' to the terminal.
|
||||
|
@ -0,0 +1,27 @@
|
||||
upgradePurchasedServer() Netscript Function
|
||||
===================================
|
||||
|
||||
.. js:function:: upgradePurchasedServer(hostname, ram)
|
||||
|
||||
:RAM cost: 0.25 GB
|
||||
:param string hostname: Hostname of the purchased server.
|
||||
:param number ram: Amount of RAM of the purchased server. Must be a power of
|
||||
2. Maximum value of :doc:`getPurchasedServerMaxRam<getPurchasedServerMaxRam>`
|
||||
:returns: ``true`` if the upgrade succeeded, ``false`` otherwise
|
||||
|
||||
Upgrades the purchased server with the specified hostname to have specified amount of RAM.
|
||||
|
||||
The ``hostname`` argument can be any data type, but it will be converted to
|
||||
a string and have whitespace removed. New RAM amount has to be higher than the current RAM
|
||||
and a power of 2. Upgrading a server costs the difference of old RAM server cost and new RAM
|
||||
server cost.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
const ram = 64;
|
||||
const name = "pserv-";
|
||||
for (const i = 0; i < 5; ++i) {
|
||||
ns.upgradePurchasedServer(name + i, ram);
|
||||
}
|
@ -27,5 +27,5 @@ weaken() Netscript Function
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
weaken("foodnstuff");
|
||||
weaken("foodnstuff", { threads: 5 }); // Only use 5 threads to weaken
|
||||
await ns.weaken("foodnstuff");
|
||||
await ns.weaken("foodnstuff", { threads: 5 }); // Only use 5 threads to weaken
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
Netscript 1.0
|
||||
=============
|
||||
|
||||
.. note:: Note that NS1/.script is being deprecated, avoid using and migrate
|
||||
scripts to NS2/.js if possible.
|
||||
|
||||
Netscript 1.0 is implemented using a modified version of Neil Fraser's
|
||||
`JS-Interpreter <https://github.com/NeilFraser/JS-Interpreter>`_.
|
||||
|
||||
|
@ -52,9 +52,11 @@ This includes information such as function signatures, what they do, and their r
|
||||
getPurchasedServerCost() <basicfunctions/getPurchasedServerCost>
|
||||
purchaseServer() <basicfunctions/purchaseServer>
|
||||
deleteServer() <basicfunctions/deleteServer>
|
||||
upgradePurchasedServer() <basicfunctions/upgradePurchasedServer>
|
||||
getPurchasedServers() <basicfunctions/getPurchasedServers>
|
||||
getPurchasedServerLimit() <basicfunctions/getPurchasedServerLimit>
|
||||
getPurchasedServerMaxRam() <basicfunctions/getPurchasedServerMaxRam>
|
||||
getPurchasedServerUpgradeCost() <basicfunctions/getPurchasedServerUpgradeCost>
|
||||
scriptRunning() <basicfunctions/scriptRunning>
|
||||
scriptKill() <basicfunctions/scriptKill>
|
||||
getScriptRam() <basicfunctions/getScriptRam>
|
@ -72,59 +72,64 @@ The following is an example of one way a script can be used to automate the
|
||||
purchasing and upgrading of Hacknet Nodes.
|
||||
|
||||
This script attempts to purchase Hacknet Nodes until the player has a total of 8. Then
|
||||
it gradually upgrades those Node's to a minimum of level 80, 16 GB RAM, and 8 cores
|
||||
it gradually upgrades those Node's to level 80, 16 GB RAM, and 8 cores
|
||||
|
||||
.. code:: javascript
|
||||
|
||||
function myMoney() {
|
||||
return getServerMoneyAvailable("home");
|
||||
}
|
||||
|
||||
disableLog("getServerMoneyAvailable");
|
||||
disableLog("sleep");
|
||||
|
||||
var cnt = 8;
|
||||
|
||||
while(hacknet.numNodes() < cnt) {
|
||||
res = hacknet.purchaseNode();
|
||||
print("Purchased hacknet Node with index " + res);
|
||||
};
|
||||
|
||||
for (var i = 0; i < cnt; i++) {
|
||||
while (hacknet.getNodeStats(i).level <= 80) {
|
||||
var cost = hacknet.getLevelUpgradeCost(i, 10);
|
||||
while (myMoney() < cost) {
|
||||
print("Need $" + cost + " . Have $" + myMoney());
|
||||
sleep(3000);
|
||||
export async function main(ns) {
|
||||
function myMoney() {
|
||||
return ns.getServerMoneyAvailable("home");
|
||||
}
|
||||
res = hacknet.upgradeLevel(i, 10);
|
||||
};
|
||||
};
|
||||
|
||||
print("All nodes upgraded to level 80");
|
||||
ns.disableLog("getServerMoneyAvailable");
|
||||
ns.disableLog("sleep");
|
||||
|
||||
for (var i = 0; i < cnt; i++) {
|
||||
while (hacknet.getNodeStats(i).ram < 16) {
|
||||
var cost = hacknet.getRamUpgradeCost(i, 2);
|
||||
while (myMoney() < cost) {
|
||||
print("Need $" + cost + " . Have $" + myMoney());
|
||||
sleep(3000);
|
||||
}
|
||||
res = hacknet.upgradeRam(i, 2);
|
||||
};
|
||||
};
|
||||
const cnt = 8;
|
||||
|
||||
print("All nodes upgraded to 16GB RAM");
|
||||
while (ns.hacknet.numNodes() < cnt) {
|
||||
res = ns.hacknet.purchaseNode();
|
||||
if (res != -1) ns.print("Purchased hacknet Node with index " + res);
|
||||
await ns.sleep(1000);
|
||||
};
|
||||
|
||||
for (var i = 0; i < cnt; i++) {
|
||||
while (hacknet.getNodeStats(i).cores < 8) {
|
||||
var cost = hacknet.getCoreUpgradeCost(i, 1);
|
||||
while (myMoney() < cost) {
|
||||
print("Need $" + cost + " . Have $" + myMoney());
|
||||
sleep(3000);
|
||||
}
|
||||
res = hacknet.upgradeCore(i, 1);
|
||||
};
|
||||
};
|
||||
ns.tprint("All " + cnt + " nodes purchased")
|
||||
|
||||
print("All nodes upgraded to 8 cores");
|
||||
for (const i = 0; i < cnt; i++) {
|
||||
while (ns.hacknet.getNodeStats(i).level <= 80) {
|
||||
var cost = ns.hacknet.getLevelUpgradeCost(i, 1);
|
||||
while (myMoney() < cost) {
|
||||
ns.print("Need $" + cost + " . Have $" + myMoney());
|
||||
await ns.sleep(3000);
|
||||
}
|
||||
res = ns.hacknet.upgradeLevel(i, 1);
|
||||
};
|
||||
};
|
||||
|
||||
ns.tprint("All nodes upgraded to level 80");
|
||||
|
||||
for (var i = 0; i < cnt; i++) {
|
||||
while (ns.hacknet.getNodeStats(i).ram < 16) {
|
||||
var cost = ns.hacknet.getRamUpgradeCost(i, 1);
|
||||
while (myMoney() < cost) {
|
||||
ns.print("Need $" + cost + " . Have $" + myMoney());
|
||||
await ns.sleep(3000);
|
||||
}
|
||||
res = ns.hacknet.upgradeRam(i, 1);
|
||||
};
|
||||
};
|
||||
|
||||
ns.tprint("All nodes upgraded to 16GB RAM");
|
||||
|
||||
for (var i = 0; i < cnt; i++) {
|
||||
while (ns.hacknet.getNodeStats(i).cores < 8) {
|
||||
var cost = ns.hacknet.getCoreUpgradeCost(i, 1);
|
||||
while (myMoney() < cost) {
|
||||
ns.print("Need $" + cost + " . Have $" + myMoney());
|
||||
await ns.sleep(3000);
|
||||
}
|
||||
res = ns.hacknet.upgradeCore(i, 1);
|
||||
};
|
||||
};
|
||||
|
||||
ns.tprint("All nodes upgraded to 8 cores");
|
||||
}
|
@ -33,8 +33,12 @@ Let's assume Port 1 starts out empty (no data inside). We'll represent the port
|
||||
|
||||
Now assume we ran the following simple script::
|
||||
|
||||
for (i = 0; i < 10; ++i) {
|
||||
writePort(1, i); //Writes the value of i to port 1
|
||||
.. code:: javascript
|
||||
|
||||
export async function main(ns) {
|
||||
for (const i = 0; i < 10; ++i) {
|
||||
ns.writePort(1, i); //Writes the value of i to port 1
|
||||
}
|
||||
}
|
||||
|
||||
After this script executes, our script will contain every number from 0 through 9, as so::
|
||||
@ -43,8 +47,12 @@ After this script executes, our script will contain every number from 0 through
|
||||
|
||||
Then, assume we run the following script::
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
print(readPort(1)); //Reads a value from port 1 and then prints it
|
||||
.. code:: javascript
|
||||
|
||||
export async function main(ns) {
|
||||
for (const i = 0; i < 3; ++i) {
|
||||
ns.print(ns.readPort(1)); //Reads a value from port 1 and then prints it
|
||||
}
|
||||
}
|
||||
|
||||
This script above will read the first three values from port 1 and then print them to the script's log. The log will end up looking like::
|
||||
@ -112,22 +120,25 @@ This handle allows you to access several new port-related functions. The functio
|
||||
|
||||
Port Handle Example::
|
||||
|
||||
port = getPortHandle(5);
|
||||
back = port.data.pop(); //Get and remove last element in port
|
||||
.. code:: javascript
|
||||
|
||||
//Wait for port data before reading
|
||||
while(port.empty()) {
|
||||
sleep(10000);
|
||||
export async function main(ns) {
|
||||
port = ns.getPortHandle(5);
|
||||
back = port.data.pop(); //Get and remove last element in port
|
||||
|
||||
//Wait for port data before reading
|
||||
while(port.empty()) {
|
||||
await ns.sleep(10000);
|
||||
}
|
||||
res = port.read();
|
||||
|
||||
//Wait for there to be room in a port before writing
|
||||
while (!port.tryWrite(5)) {
|
||||
await ns.sleep(5000);
|
||||
}
|
||||
|
||||
//Successfully wrote to port!
|
||||
}
|
||||
res = port.read();
|
||||
|
||||
//Wait for there to be room in a port before writing
|
||||
while (!port.tryWrite(5)) {
|
||||
sleep(5000);
|
||||
}
|
||||
|
||||
//Successfully wrote to port!
|
||||
|
||||
|
||||
Comments
|
||||
--------
|
||||
@ -138,7 +149,7 @@ Comments are not evaluated as code, and can be used to document and/or explain c
|
||||
/* Multi
|
||||
* line
|
||||
* comment */
|
||||
print("This code will actually get executed");
|
||||
ns.print("This code will actually get executed");
|
||||
|
||||
.. _netscriptimporting:
|
||||
|
||||
@ -152,57 +163,70 @@ There are two ways of doing this::
|
||||
import * as namespace from "script filename"; //Import all functions from script
|
||||
import {fn1, fn2, ...} from "script filename"; //Import specific functions from script
|
||||
|
||||
Suppose you have a library script called *testlibrary.script*::
|
||||
Suppose you have a library script called *testlibrary.js*::
|
||||
|
||||
function foo1(args) {
|
||||
.. code:: javascript
|
||||
|
||||
export function foo1(args) {
|
||||
//function definition...
|
||||
}
|
||||
|
||||
function foo2(args) {
|
||||
export function foo2(args) {
|
||||
//function definition...
|
||||
}
|
||||
|
||||
function foo3(args) {
|
||||
export async function foo3(args) {
|
||||
//function definition...
|
||||
}
|
||||
|
||||
function foo4(args) {
|
||||
export function foo4(args) {
|
||||
//function definition...
|
||||
}
|
||||
|
||||
export async function main(ns) {
|
||||
//main function definition, can be empty but must exist...
|
||||
}
|
||||
|
||||
Then, if you wanted to use these functions in another script, you can import them like so::
|
||||
|
||||
import * as testlib from "testlibrary.script";
|
||||
.. code:: javascript
|
||||
|
||||
values = [1,2,3];
|
||||
import * as testlib from "testlibrary.js";
|
||||
|
||||
//The imported functions must be specified using the namespace
|
||||
someVal1 = testlib.foo3(values);
|
||||
someVal2 = testlib.foo1(values);
|
||||
if (someVal1 > someVal2) {
|
||||
//...
|
||||
} else {
|
||||
//...
|
||||
export async function main(ns) {
|
||||
const values = [1,2,3];
|
||||
|
||||
//The imported functions must be specified using the namespace
|
||||
const someVal1 = await testlib.foo3(...values); //'...' separates the array into separate values
|
||||
const someVal2 = testlib.foo1(values[0]);
|
||||
if (someVal1 > someVal2) {
|
||||
//...
|
||||
} else {
|
||||
//...
|
||||
}
|
||||
}
|
||||
|
||||
If you only wanted to import certain functions, you can do so without needing
|
||||
to specify a namespace for the import::
|
||||
|
||||
import {foo1, foo3} from "testlibrary.script"; //Saves RAM since not all functions are imported!
|
||||
.. code:: javascript
|
||||
|
||||
values = [1,2,3];
|
||||
import {foo1, foo3} from "testlibrary.js"; //Saves RAM since not all functions are imported!
|
||||
|
||||
//No namespace needed
|
||||
someVal1 = foo3(values);
|
||||
someVal2 = foo1(values);
|
||||
if (someVal1 > someVal2) {
|
||||
//...
|
||||
} else {
|
||||
//...
|
||||
export async function main(ns) {
|
||||
const values = [1,2,3];
|
||||
|
||||
//No namespace needed
|
||||
const someVal1 = await foo3(...values);
|
||||
const someVal2 = foo1(values[1]);
|
||||
if (someVal1 > someVal2) {
|
||||
//...
|
||||
} else {
|
||||
//...
|
||||
}
|
||||
}
|
||||
|
||||
.. warning:: For those who are experienced with JavaScript, note that the `export`
|
||||
keyword should **NOT** be used in :ref:`netscript1`, as this will break the script.
|
||||
.. warning:: Note that the `export` keyword can **NOT** be used in :ref:`netscript1` as it's not supported.
|
||||
It can, however, be used in :ref:`netscriptjs` (but it's not required).
|
||||
|
||||
Standard, Built-In JavaScript Objects
|
||||
|
@ -15,6 +15,8 @@ argument will be a number. This generic script will run the
|
||||
script specified in the first argument with the amount of threads
|
||||
specified in the second argument. The code would look like::
|
||||
|
||||
.. code:: javascript
|
||||
|
||||
run(args[0], args[1]);
|
||||
|
||||
And it could be ran from the terminal like:
|
||||
@ -23,9 +25,11 @@ And it could be ran from the terminal like:
|
||||
|
||||
In .js / ns2, the above script would look like::
|
||||
|
||||
export async function main(ns) {
|
||||
ns.run(ns.args[0], ns.args[1]);
|
||||
}
|
||||
.. code:: javascript
|
||||
|
||||
export async function main(ns) {
|
||||
ns.run(ns.args[0], ns.args[1]);
|
||||
}
|
||||
|
||||
It is also possible to get the number of arguments that were passed
|
||||
into a script using ``args.length``.
|
||||
|
@ -1,4 +1,5 @@
|
||||
Sphinx==1.8.5
|
||||
sphinx-rtd-theme==0.4.3
|
||||
sphinxcontrib-newsfeed==0.1.4
|
||||
docutils==0.17.1
|
||||
docutils==0.17.1
|
||||
Jinja2==3.0.3
|
Loading…
Reference in New Issue
Block a user