mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 09:42:53 +02:00
Various QOL improvements and bug fixes
This commit is contained in:
@@ -454,3 +454,48 @@ do not allow cross-origin origin sharing (CORS). This includes websites such
|
||||
as gist and pastebin. One notable site it will work on is rawgithub. Example::
|
||||
|
||||
$ wget https://raw.githubusercontent.com/danielyxie/bitburner/master/README.md game_readme.txt
|
||||
|
||||
Argument Parsing
|
||||
----------------
|
||||
When evaluating a terminal command, arguments are initially parsed based on whitespace (usually spaces).
|
||||
Each whitespace character signifies the end of an argument, and potentially the start
|
||||
of new one. For most terminal commands, this is all you need to know.
|
||||
|
||||
When running scripts, however, it is important to know in more detail how arguments are parsed.
|
||||
There are two main points:
|
||||
|
||||
1. Quotation marks can be used to wrap a single argument and force it to be parsed as
|
||||
a string. Any whitespace inside the quotation marks will not cause a new argument
|
||||
to be parsed.
|
||||
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]);
|
||||
}
|
||||
|
||||
Then if we run the following terminal command::
|
||||
|
||||
$ run argType.script 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
|
||||
|
||||
Chaining Commands
|
||||
-----------------
|
||||
You can run multiple Terminal commands at once by separating each command
|
||||
with a semicolon (;).
|
||||
|
||||
Example::
|
||||
|
||||
$ run foo.script; tail foo.script
|
||||
|
||||
@@ -1211,6 +1211,26 @@ vsprintf
|
||||
|
||||
See `this link <https://github.com/alexei/sprintf.js>`_ for details.
|
||||
|
||||
nFormat
|
||||
^^^^^^^
|
||||
|
||||
.. js:function:: nFormat(n, format)
|
||||
|
||||
:param number n: Number to format
|
||||
:param string format: Formatter
|
||||
|
||||
Converts a number into a string with the specified formatter. This uses the
|
||||
`numeraljs <http://numeraljs.com/>`_ library, so the formatters must be compatible
|
||||
with that.
|
||||
|
||||
This is the same function that the game itself uses to display numbers.
|
||||
|
||||
Examples::
|
||||
|
||||
nFormat(1.23e9, "$0.000a"); // Returns "$1.230b"
|
||||
nFormat(12345.678, "0,0"); // Returns "12,346"
|
||||
nFormat(0.84, "0.0%"); // Returns "84.0%
|
||||
|
||||
prompt
|
||||
^^^^^^
|
||||
|
||||
|
||||
@@ -209,7 +209,19 @@ to specify a namespace for the import::
|
||||
//...
|
||||
}
|
||||
|
||||
Note that exporting functions is not required.
|
||||
.. 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.
|
||||
It can, however, be used in :ref:`netscriptjs` (but it's not required).
|
||||
|
||||
Importing in NetscriptJS
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
There is a minor annoyance when using the `import` feature in :ref:`netscriptjs`.
|
||||
If you make a change in a NetscriptJS script, then you have to manually "refresh" all other
|
||||
scripts that import from that script.
|
||||
|
||||
The easiest way to do this is to simply save and then refresh the game. Alternatively,
|
||||
you can open up all the scripts that need to be "refreshed" in the script editor
|
||||
and then simply re-save them.
|
||||
|
||||
Standard, Built-In JavaScript Objects
|
||||
-------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user