Merge pull request #343 from Mughur/docupdate

DOC: Doc changes
This commit is contained in:
Mughur 2023-01-30 21:02:43 +02:00 committed by GitHub
commit 0c7b6a8ad8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 244 additions and 3 deletions

@ -218,7 +218,7 @@ List of Factions and their Requirements
| | The Covenant | * 20 Augmentations | | | | The Covenant | * 20 Augmentations | |
| | | * $75b | | | | | * $75b | |
| | | * Hacking Level of 850 | | | | | * Hacking Level of 850 | |
| | | * or All Combat Stats of 850 | | | | | * All Combat Stats of 850 | |
+ +----------------+-----------------------------------------+-------------------------------+ + +----------------+-----------------------------------------+-------------------------------+
| | Daedalus | * 30 Augmentations | | | | Daedalus | * 30 Augmentations | |
| | | * $100b | | | | | * $100b | |

@ -0,0 +1,15 @@
clearLog() Netscript Function
===============================
.. js:function:: clearLog()
:RAM cost: 0 GB
Clears the scripts logs.
Examples:
.. code-block:: javascript
//Opens the logs, clears it of whatever may have been there before and prevents non-print() functions from printing to log
ns.tail();ns.clearLog();ns.disableLog("ALL");

@ -0,0 +1,19 @@
closeTail() Netscript Function
===============================
.. js:function:: closeTail([scriptPid])
:RAM cost: 0 GB
:param number scriptPid: PID of the script of which to open the logs.
Closes a scripts logs.
If the function is called with no arguments, it will open the current scripts logs.
Examples:
.. code-block:: javascript
ns.closeTail(12);
ns.closeTail();

@ -8,4 +8,11 @@ disableLog() Netscript Function
:param string functionName: Name of function for which to disable logging. :param string functionName: Name of function for which to disable logging.
Disables logging for the given function. Logging can be disabled for Disables logging for the given function. Logging can be disabled for
all functions by passing 'ALL' as the argument. all functions by passing 'ALL' as the argument. Print() can always print to log.
Examples:
.. code-block:: javascript
//Opens the logs, clears it of whatever may have been there before and prevents non-print() functions from logging
ns.tail();ns.clearLog();ns.disableLog("ALL");

@ -10,3 +10,12 @@ enableLog() Netscript Function
Re-enables logging for the given function. If 'ALL' is passed into this Re-enables logging for the given function. If 'ALL' is passed into this
function as an argument, then it will revert the effects of function as an argument, then it will revert the effects of
``disableLog('ALL')`` ``disableLog('ALL')``
Examples:
.. code-block:: javascript
//Opens the logs, clears it of whatever may have been there before and prevents non-print() functions from printing to log
ns.tail();ns.clearLog();ns.disableLog("ALL");
//let hack() log normally
ns.enableLog("hack");

@ -0,0 +1,14 @@
getHostname() Netscript Function
==============================
.. js:function:: getHostname()
:RAM cost: 0.05 GB
Returns a string with the hostname of the server that the script is running on.
Examples:
.. code-block:: javascript
ns.tprint(ns.getHostname())

@ -0,0 +1,15 @@
getSharePower() Netscript Function
==============================
.. js:function:: getSharePower()
:RAM cost: 0.2 GB
Calculate your share power. Based on all the active share calls.
Returns the reputation gain rate multiplier, i.e. 1.5 means +50% rep gain rate.
Examples:
.. code-block:: javascript
ns.tprint(ns.getSharePower())

@ -2,6 +2,7 @@ isRunning() Netscript Function
============================== ==============================
.. js:function:: isRunning(filename[, hostname=current hostname[, args...]]) .. js:function:: isRunning(filename[, hostname=current hostname[, args...]])
.. js:function:: isRunning(PID)
:RAM cost: 0.1 GB :RAM cost: 0.1 GB
:param string filename: Filename of script to check. case-sensitive. :param string filename: Filename of script to check. case-sensitive.

@ -2,6 +2,7 @@ kill() Netscript Function
========================= =========================
.. js:function:: kill(script, [hostname=current hostname, [args...]]) .. js:function:: kill(script, [hostname=current hostname, [args...]])
.. js:function:: kill(PID)
:RAM cost: 0.5 GB :RAM cost: 0.5 GB
:param string script: Filename of the script to kill. :param string script: Filename of the script to kill.

@ -0,0 +1,28 @@
moveTail() Netscript Function
===============================
.. js:function:: moveTail(x , y[, pid])
:RAM cost: 0 GB
:param number x: X coordinate to move the tail window to.
:param number y: Y coordinate to move the tail window to.
:param number pid: PID of the script of which tail window to move. Defaults to current script.
Moves the tail window to the specified coordinates. The top left corner is (0,0).
.. note::
Due to inner workings, something has to be awaited between opening a tail window and moving or resizing it.
Examples:
.. code-block:: javascript
//open tail
ns.tail();
await ns.sleep(0);
//move the tail close to top left corner and make it big
ns.moveTail(10, 10);
ns.resizeTail(780, 510)

@ -0,0 +1,18 @@
mv() Netscript Function
==============================
.. js:function:: mv(serverName, sourceFile, targetFile)
:RAM cost: 0 GB
Move the source file to target file on the given server.
This command only works for scripts and text files (.txt). It cannot, however, be used to convert from script to text file, or vice versa.
This function can also be used to rename files.
Examples:
.. code-block:: javascript
ns.tprint("home", "foo.js", "old_foo.txt")

@ -0,0 +1,20 @@
nFormat() Netscript Function
==============================
.. js:function:: nFormat(number, format)
:RAM cost: 0 GB
:param number number: Number to format.
:param string format: Formatting to use. Read http://numeraljs.com/#format for specifics.
onverts a number into a string with the specified formatter.
This uses the numeral.js library, so the formatters must be compatible with that.
Examples:
.. code-block:: javascript
ns.print(ns.nFormat(123456789.1,"0,0")) //logs "123,456,789"
ns.print(ns.nFormat(123456789.1,"0.00a")) //logs "123.46m"
ns.print(ns.nFormat(200000,"$0.00a")) //logs "$200.00k"

@ -0,0 +1,28 @@
moveTail() Netscript Function
===============================
.. js:function:: moveTail(width, heigth[, pid])
:RAM cost: 0 GB
:param number width: Width of the window.
:param number heigth: Heigth of the window.
:param number pid: PID of the script of which tail window to resize. Defaults to current script.
resizes the tail window to the specified size.
.. note::
Due to inner workings, something has to be awaited between opening a tail window and moving or resizing it.
Examples:
.. code-block:: javascript
//open tail
ns.tail();
await ns.sleep(0);
//move the tail close to top left corner and make it big
ns.moveTail(10, 10);
ns.resizeTail(780, 510)

@ -0,0 +1,14 @@
share() Netscript Function
==============================
.. js:function:: share()
:RAM cost: 2.4 GB
Increases your rep gain of all faction work types while share is called. Scales with thread count.
Examples:
.. code-block:: javascript
while(true) await ns.share();

@ -0,0 +1,34 @@
tail() Netscript Function
===============================
.. js:function:: tail([script, hostname[, numThreads=1[, args...]]])
:RAM cost: 0 GB
:param string script: Filename of the script of which to open the logs.
:param string hostname: Hostname of the server on which the script is running on.
:param args...: Arguments to identify which script's log to open.
Opens a scripts logs. This is functionally the same as the tail Terminal command.
If the function is called with no arguments, it will open the current scripts logs.
Examples:
.. code-block:: javascript
ns.tail("foo.js", "foodnstuff");
ns.tail();
.. js:function:: tail(scriptPid)
:RAM cost: 0 GB
:param number scriptPid: PID of the script of which to open the logs.
Same as the above version but with pid.
Example:
.. code-block:: javascript
ns.tail(12);

@ -0,0 +1,18 @@
tFormat() Netscript Function
==============================
.. js:function:: tFormat(milliseconds[, milliPrecision])
:RAM cost: 0 GB
:param string milliseconds: Number of millisecond to format.
:param boolean milliPrecision: Format time with subsecond precision. Defaults to false.
Format time to a readable string.
Examples:
.. code-block:: javascript
ns.print(ns.tFormat(123456789)) //logs "1 day 10 hours 17 minutes 36 seconds"
ns.print(ns.tFormat(123456789,true)) //logs "1 day 10 hours 17 minutes 36.789 seconds"

@ -6854,7 +6854,7 @@ export type NS = {
* @remarks * @remarks
* RAM cost: 2.4 GB * RAM cost: 2.4 GB
* *
* Increases your rep gain of hacking contracts while share is called. * Increases your rep gain of all faction work types while share is called.
* Scales with thread count. * Scales with thread count.
*/ */
share(): Promise<void>; share(): Promise<void>;