mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-18 07:18:38 +02:00
Massive doc update
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user