mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 14:28:36 +02:00
v0.51.5 (#848)
This commit is contained in:
40
doc/source/netscript/basicfunctions/flags.rst
Normal file
40
doc/source/netscript/basicfunctions/flags.rst
Normal file
@@ -0,0 +1,40 @@
|
||||
flags() Netscript Function
|
||||
============================
|
||||
|
||||
.. js:function:: flags(data)
|
||||
|
||||
:RAM cost: 0 GB
|
||||
:param data array of pairs of strings: Flags definition.
|
||||
:returns: Object containing all the flags that were parsed or default.
|
||||
|
||||
The flag definition is an array of pairs of values, the first value is the
|
||||
name of the flag, the 2nd value is the default value for that flag.
|
||||
|
||||
The return object is a map containing flag names to the value. It also
|
||||
contains the special field '_' which contains all arguments that were not flags.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
/* example.script
|
||||
var data = flags([
|
||||
['delay', 0], // a default number means this flag is a number
|
||||
['server', 'foodnstuff'], // a default string means this flag is a string
|
||||
['exclude', []], // a default array means this flag is a default array of string
|
||||
['help', false], // a default boolean means this flag is a boolean
|
||||
]);
|
||||
tprint(data);
|
||||
*/
|
||||
[home ~/]> run example.script
|
||||
{"_":[],"delay":0,"server":"foodnstuff"}
|
||||
[home ~/]> run example.script --delay 3000
|
||||
{"_":[],"server":"foodnstuff","delay":3000}
|
||||
[home ~/]> run example.script --delay 3000 --server harakiri-sushi
|
||||
{"_":[],"delay":3000,"server":"harakiri-sushi"}
|
||||
[home ~/]> run example.script --delay 3000 --server harakiri-sushi hello world
|
||||
{"_":["hello","world"],"delay":3000,"server":"harakiri-sushi"}
|
||||
[home ~/]> run example.script --delay 3000 --server harakiri-sushi hello world --exclude a --exclude b
|
||||
{"_":["hello","world"],"delay":3000,"server":"harakiri-sushi","exclude":["a","b"]}
|
||||
[home ~/]> run example.script --help
|
||||
{"_":[],"delay":0,"server":"foodnstuff","exclude":[],"help":true}
|
||||
@@ -1,11 +1,11 @@
|
||||
isRunning() Netscript Function
|
||||
==============================
|
||||
|
||||
.. js:function:: isRunning(filename, hostname, [args...])
|
||||
.. js:function:: isRunning(filename[, hostname=current hostname[, args...]])
|
||||
|
||||
:RAM cost: 0.1 GB
|
||||
:param string filename: Filename of script to check. case-sensitive.
|
||||
:param string hostname: Hostname of target server.
|
||||
:param string hostname: Hostname of target server. Defaults to current server
|
||||
:param args...: Arguments to specify/identify which scripts to search for
|
||||
:returns: ``true`` if that script with those args is running on that server.
|
||||
|
||||
@@ -38,3 +38,19 @@ isRunning() Netscript Function
|
||||
.. code-block:: javascript
|
||||
|
||||
isRunning("foo.script", "joesguns", 1, 5, "test");
|
||||
|
||||
|
||||
.. js:function:: isRunning(scriptPid[, hostname=current hostname])
|
||||
|
||||
:RAM cost: 0.1 GB
|
||||
:param number scriptPid: PID of the script to check.
|
||||
|
||||
Same as the above version but with pid.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
isRunning(39);
|
||||
|
||||
isRunning(39, getHostname());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tail() Netscript Function
|
||||
==================================
|
||||
|
||||
.. js:function:: tail([fn[, hostname=current hostname[, [...args]]])
|
||||
.. js:function:: tail([fn[, hostname=current hostname[, ...args]])
|
||||
|
||||
:RAM cost: 0 GB
|
||||
:param string fn: Optional. Filename of script to get logs from.
|
||||
@@ -29,3 +29,20 @@ tail() Netscript Function
|
||||
|
||||
// Open logs from foo.script on the foodnstuff server that was run with the arguments [1, "test"]
|
||||
tail("foo.script", "foodnstuff", 1, "test");
|
||||
|
||||
.. js:function:: tail(scriptPid[, hostname=current hostname])
|
||||
|
||||
:RAM cost: 0 GB
|
||||
:param number scriptPid: PID of the script to tail.
|
||||
|
||||
Opens a script's logs by pid
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
// Open logs from process with id 42
|
||||
tail(42);
|
||||
|
||||
// Open logs from process with id 42 on the foodnstuff server
|
||||
tail(42, "foodnstuff");
|
||||
|
||||
Reference in New Issue
Block a user