mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 14:28:36 +02:00
v0.44.1 Minor Update - Added Augs to Duplicate Sleeves and updated documentation
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
.. _netscripthacknetnodeapi:
|
||||
.. _netscript_hacknetnodeapi:
|
||||
|
||||
Netscript Hacknet Node API
|
||||
==========================
|
||||
@@ -21,6 +21,22 @@ In :ref:`netscriptjs`::
|
||||
ns.hacknet.purchaseNode();
|
||||
ns.hacknet.getNodeStats(3).level;
|
||||
|
||||
.. toctree::
|
||||
:caption: API Functions:
|
||||
|
||||
numNodes() <hacknetnodeapi/numNodes>
|
||||
purchaseNode() <hacknetnodeapi/purchaseNode>
|
||||
getPurchaseNodeCost() <hacknetnodeapi/getPurchaseNodeCost>
|
||||
getNodeStats() <hacknetnodeapi/getNodeStats>
|
||||
upgradeLevel() <hacknetnodeapi/upgradeLevel>
|
||||
upgradeRam() <hacknetnodeapi/upgradeRam>
|
||||
upgradeCore() <hacknetnodeapi/upgradeCore>
|
||||
getLevelUpgradeCost() <hacknetnodeapi/getLevelUpgradeCost>
|
||||
getRamUpgradeCost() <hacknetnodeapi/getRamUpgradeCost>
|
||||
getCoreUpgradeCost() <hacknetnodeapi/getCoreUpgradeCost>
|
||||
|
||||
.. _netscript_hacknetnodeapi_referencingahacknetnode:
|
||||
|
||||
Referencing a Hacknet Node
|
||||
--------------------------
|
||||
Most of the functions in the Hacknet Node API perform an operation on a single
|
||||
@@ -35,128 +51,7 @@ RAM Cost
|
||||
--------
|
||||
Accessing the `hacknet` namespace incurs a one time cost of 4 GB of RAM.
|
||||
In other words, using multiple Hacknet Node API functions in a script will not cost
|
||||
more than 4 GB of RAM.
|
||||
|
||||
numNodes
|
||||
--------
|
||||
.. js:function:: numNodes()
|
||||
|
||||
Returns the number of Hacknet Nodes you own.
|
||||
|
||||
purchaseNode
|
||||
------------
|
||||
.. js:function:: purchaseNode()
|
||||
|
||||
Purchases a new Hacknet Node. Returns a number with the index of the Hacknet Node.
|
||||
This index is equivalent to the number at the end of the Hacknet Node's name
|
||||
(e.g The Hacknet Node named 'hacknet-node-4' will have an index of 4).
|
||||
|
||||
If the player cannot afford to purchase a new Hacknet Node then the function
|
||||
will return -1.
|
||||
|
||||
getPurchaseNodeCost
|
||||
-------------------
|
||||
.. js:function:: getPurchaseNodeCost()
|
||||
|
||||
Returns the cost of purchasing a new Hacknet Node
|
||||
|
||||
getNodeStats
|
||||
------------
|
||||
.. js:function:: getNodeStats(i)
|
||||
|
||||
:param number i: Index/Identifier of Hacknet Node
|
||||
|
||||
Returns an object containing a variety of stats about the specified Hacknet Node::
|
||||
|
||||
{
|
||||
name: Node's name ("hacknet-node-5"),
|
||||
level: Node's level,
|
||||
ram: Node's RAM,
|
||||
cores: Node's number of cores,
|
||||
production: Node's money earned per second,
|
||||
timeOnline: Number of seconds since Node has been purchased,
|
||||
totalProduction: Total number of money Node has produced
|
||||
}
|
||||
|
||||
upgradeLevel
|
||||
------------
|
||||
.. js:function:: upgradeLevel(i, n)
|
||||
|
||||
:param number i: Index/Identifier of Hacknet Node
|
||||
:param number n: Number of levels to purchase. Must be positive. Rounded to nearest integer
|
||||
|
||||
Tries to upgrade the level of the specified Hacknet Node by *n*.
|
||||
|
||||
Returns true if the Hacknet Node's level is successfully upgraded by *n* or
|
||||
if it is upgraded by some positive amount and the Node reaches its max level.
|
||||
|
||||
Returns false otherwise.
|
||||
|
||||
upgradeRam
|
||||
----------
|
||||
.. js:function:: upgradeRam(i, n)
|
||||
|
||||
:param number i: Index/Identifier of Hacknet Node
|
||||
:param number n: Number of times to upgrade RAM. Must be positive. Rounded to nearest integer
|
||||
|
||||
Tries to upgrade the specified Hacknet Node's RAM *n* times. Note that each upgrade
|
||||
doubles the Node's RAM. So this is equivalent to multiplying the Node's RAM by
|
||||
2 :sup:`n`.
|
||||
|
||||
Returns true if the Hacknet Node's RAM is successfully upgraded *n* times or if
|
||||
it is upgraded some positive number of times and the Node reaches it max RAM.
|
||||
|
||||
Returns false otherwise.
|
||||
|
||||
upgradeCore
|
||||
-----------
|
||||
.. js:function:: upgradeCore(i, n)
|
||||
|
||||
:param number i: Index/Identifier of Hacknet Node
|
||||
:param number n: Number of cores to purchase. Must be positive. Rounded to nearest integer
|
||||
|
||||
Tries to purchase *n* cores for the specified Hacknet Node.
|
||||
|
||||
Returns true if it successfully purchases *n* cores for the Hacknet Node or if
|
||||
it purchases some positive amount and the Node reaches its max number of cores.
|
||||
|
||||
Returns false otherwise.
|
||||
|
||||
getLevelUpgradeCost
|
||||
-------------------
|
||||
.. js:function:: getLevelUpgradeCost(i, n)
|
||||
|
||||
:param number i: Index/Identifier of Hacknet Node
|
||||
:param number n: Number of levels to upgrade. Must be positive. Rounded to nearest integer
|
||||
|
||||
Returns the cost of upgrading the specified Hacknet Node by *n* levels.
|
||||
|
||||
If an invalid value for *n* is provided, then this function returns 0. If the
|
||||
specified Hacknet Node is already at max level, then Infinity is returned.
|
||||
|
||||
getRamUpgradeCost
|
||||
-----------------
|
||||
.. js:function:: getRamUpgradeCost(i, n)
|
||||
|
||||
:param number i: Index/Identifier of Hacknet Node
|
||||
:param number n: Number of times to upgrade RAM. Must be positive. Rounded to nearest integer
|
||||
|
||||
Returns the cost of upgrading the RAM of the specified Hacknet Node *n* times.
|
||||
|
||||
If an invalid value for *n* is provided, then this function returns 0. If the
|
||||
specified Hacknet Node is already at max RAM, then Infinity is returned.
|
||||
|
||||
getCoreUpgradeCost
|
||||
------------------
|
||||
.. js:function:: getCoreUpgradeCost(i, n)
|
||||
|
||||
:param number i: Index/Identifier of Hacknet Node
|
||||
:param number n: Number of times to upgrade cores. Must be positive. Rounded to nearest integer
|
||||
|
||||
Returns the cost of upgrading the number of cores of the specified Hacknet Node by *n*.
|
||||
|
||||
If an invalid value for *n* is provided, then this function returns 0. If the
|
||||
specified Hacknet Node is already at the max number of cores, then Infinity is returned.
|
||||
more than 4 GB of RAM.
|
||||
|
||||
Utilities
|
||||
---------
|
||||
@@ -164,28 +59,10 @@ The following functions are not officially part of the Hacknet Node API, but the
|
||||
can be useful when writing Hacknet Node-related scripts. Since they are not part
|
||||
of the API, they do not need to be accessed using the *hacknet* namespace.
|
||||
|
||||
.. js:function:: getHacknetMultipliers()
|
||||
|
||||
Returns an object containing the Player's hacknet related multipliers. These multipliers are
|
||||
returned in integer forms, not percentages (e.g. 1.5 instead of 150%). The object has the following structure::
|
||||
|
||||
{
|
||||
production: Player's hacknet production multiplier,
|
||||
purchaseCost: Player's hacknet purchase cost multiplier,
|
||||
ramCost: Player's hacknet ram cost multiplier,
|
||||
coreCost: Player's hacknet core cost multiplier,
|
||||
levelCost: Player's hacknet level cost multiplier
|
||||
}
|
||||
|
||||
Example of how this can be used::
|
||||
|
||||
mults = getHacknetMultipliers();
|
||||
print(mults.production);
|
||||
print(mults.purchaseCost);
|
||||
|
||||
* :js:func:`getHacknetMultipliers`
|
||||
|
||||
Example(s)
|
||||
^^^^^^^^^^
|
||||
----------
|
||||
|
||||
The following is an example of one way a script can be used to automate the
|
||||
purchasing and upgrading of Hacknet Nodes.
|
||||
@@ -194,8 +71,9 @@ This script attempts to purchase Hacknet Nodes until the player has a total of 8
|
||||
it gradually upgrades those Node's to a minimum of level 140, 64 GB RAM, and 8 cores::
|
||||
|
||||
function myMoney() {
|
||||
return getServerMoneyAvailable("home");
|
||||
}
|
||||
return getServerMoneyAvailable("home");() <hacknetnodeapi/ return getServerMoneyAvailable("home");>
|
||||
}
|
||||
}() <hacknetnodeapi/>
|
||||
disableLog("getServerMoneyAvailable");
|
||||
disableLog("sleep");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user