mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-08 08:43:53 +01:00
Merge branch 'master' into dev
This commit is contained in:
commit
a53b36ed27
@ -106,7 +106,7 @@ Check how much RAM a script requires to run with n threads
|
||||
**nano [script]**
|
||||
|
||||
Create/Edit a script. The name of the script must end with a valid
|
||||
extension: .script, .js, or .ns
|
||||
extension: .script, or .js
|
||||
|
||||
**ps**
|
||||
|
||||
|
@ -425,7 +425,7 @@ nano
|
||||
|
||||
$ nano [filename]
|
||||
|
||||
Opens up the specified file in the Text Editor. Only scripts (.script, .ns, .js) and
|
||||
Opens up the specified file in the Text Editor. Only scripts (.script, .js) and
|
||||
text files (.txt) can be edited. If the file does not already exist, then a new
|
||||
empty file will be created.
|
||||
|
||||
@ -595,7 +595,7 @@ wget
|
||||
$ wget [url] [target file]
|
||||
|
||||
Retrieves data from a url and downloads it to a file on the current server.
|
||||
The data can only be downloaded to a script (.script, .ns, .js) or a text file
|
||||
The data can only be downloaded to a script (.script, .js) or a text file
|
||||
(.txt). If the target file already exists, it will be overwritten by this command.
|
||||
|
||||
Note that will not be possible to download data from many websites because they
|
||||
|
@ -7,7 +7,7 @@ autocomplete() Netscript Function
|
||||
|
||||
:RAM cost: 0 GB
|
||||
:param Object data: general data about the game you might want to autocomplete.
|
||||
:param string[] args: current arguments. Minus `run script.ns`
|
||||
:param string[] args: current arguments. Minus `run script.js`
|
||||
|
||||
data is an object with the following properties::
|
||||
|
||||
@ -34,6 +34,6 @@ autocomplete() Netscript Function
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ run demo.ns mega\t
|
||||
$ run demo.js mega\t
|
||||
// results in
|
||||
$ run demo.ns megacorp
|
||||
$ run demo.js megacorp
|
||||
|
@ -21,11 +21,11 @@ As of the time of writing this, a few browsers do not support `dynamic import <h
|
||||
How to use ns2
|
||||
----------------------
|
||||
Working with ns2 scripts is the same as ns1 scripts. The only difference
|
||||
is that ns2 scripts use the ".ns" or ".js" extension rather than ".script". E.g.::
|
||||
is that ns2 scripts use the ".js" extension rather than ".script". E.g.::
|
||||
|
||||
$ nano foo.ns
|
||||
$ run foo.ns -t 100 arg1 arg2 arg3
|
||||
exec("foo.ns", "purchasedServer1", "100", "randomArg");
|
||||
$ nano foo.js
|
||||
$ run foo.js -t 100 arg1 arg2 arg3
|
||||
exec("foo.js", "purchasedServer1", "100", "randomArg");
|
||||
|
||||
The caveat when using ns2 to write scripts is that your code must be
|
||||
asynchronous. Furthermore, instead of using the global scope and executing your code
|
||||
@ -66,9 +66,9 @@ Here is a summary of all rules you need to follow when writing Netscript JS code
|
||||
* **Do not write any infinite loops without using a** :code:`sleep` **or one of the timed Netscript functions like** :code:`hack`. Doing so will freeze your game.
|
||||
|
||||
* Any global variable declared in a ns2 script is shared between all instances of that
|
||||
script. For example, assume you write a script *foo.ns* and declared a global variable like so::
|
||||
script. For example, assume you write a script *foo.js* and declared a global variable like so::
|
||||
|
||||
//foo.ns
|
||||
//foo.js
|
||||
let globalVariable;
|
||||
|
||||
export async function main(ns) {
|
||||
@ -79,15 +79,15 @@ Here is a summary of all rules you need to follow when writing Netscript JS code
|
||||
}
|
||||
}
|
||||
|
||||
Then, you ran multiple instances of *foo.ns*::
|
||||
Then, you ran multiple instances of *foo.js*::
|
||||
|
||||
$ run foo.ns 1
|
||||
$ run foo.ns 1 2 3
|
||||
$ run foo.ns 1 2 3 4 5
|
||||
$ run foo.js 1
|
||||
$ run foo.js 1 2 3
|
||||
$ run foo.js 1 2 3 4 5
|
||||
|
||||
Then all three instances of foo.ns will share the same instance of :code:`globalVariable`.
|
||||
Then all three instances of foo.js will share the same instance of :code:`globalVariable`.
|
||||
(In this example, the value of :code:`globalVariable` will be set to 5 because the
|
||||
last instance of *foo.ns* to run has 5 arguments. This means that all three instances of
|
||||
last instance of *foo.js* to run has 5 arguments. This means that all three instances of
|
||||
the script will repeatedly print the value 5).
|
||||
|
||||
These global variables can be thought of as `C++ static class members <https://www.tutorialspoint.com/cplusplus/cpp_static_members.htm>`_,
|
||||
@ -117,7 +117,7 @@ early-hack-template.script
|
||||
}
|
||||
}
|
||||
|
||||
early-hack-template.ns
|
||||
early-hack-template.js
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
@ -151,7 +151,7 @@ You may have noticed that every new ns2 file will contains the following comment
|
||||
* @param {NS} ns
|
||||
**/
|
||||
|
||||
This comment is used to help the text editor autocomplete functions in the Netscript API. You can enabling it by pressing ctrl+space after `ns.`
|
||||
This comment is used to help the text editor autocomplete functions in the Netscript API. You can enable it by pressing ctrl+space after `ns.`
|
||||
|
||||
.. image:: autocomplete.png
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user