bitburner-src/markdown/bitburner.hacknet.md
Olivier Gagnon feb0430aff work on doc
2021-10-30 15:46:34 -04:00

5.2 KiB
Raw Blame History

Home > bitburner > Hacknet

Hacknet interface

Hacknet API

Signature:

interface Hacknet 

Methods

Method Description
getCacheUpgradeCost(index, n) This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node).Returns the cost of upgrading the cache level of the specified Hacknet Server by n.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.
getCoreUpgradeCost(index, n) 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 max level, then Infinity is returned.
getLevelUpgradeCost(index, n) 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.
getNodeStats(index) Returns an object containing a variety of stats about the specified Hacknet Node.Note that for Hacknet Nodes, production refers to the amount of money the node generates. For Hacknet Servers (the upgraded version of Hacknet Nodes), production refers to the amount of hashes the node generates.
getPurchaseNodeCost() Returns the cost of purchasing a new Hacknet Node.
getRamUpgradeCost(index, n) 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 level, then Infinity is returned.
hashCost(upgName) This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node).Returns the number of hashes required for the specified upgrade. The name of the upgrade must be an exact match.
numHashes() This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node).Returns the number of hashes you have.
numNodes() Returns the number of Hacknet Nodes you own.
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 Nodes 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.
spendHashes(upgName, upgTarget) This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node).Spend the hashes generated by your Hacknet Servers on an upgrade. Returns a boolean value - true if the upgrade is successfully purchased, and false otherwise.The name of the upgrade must be an exact match. The upgTarget argument is used for upgrades such as Reduce Minimum Security, which applies to a specific server. In this case, the upgTarget argument must be the hostname of the server.
upgradeCache(index, n) This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node).Tries to upgrade the specified Hacknet Servers cache n times.Returns true if it successfully upgrades the Servers cache n times, or if it purchases some positive amount and the Server reaches its max cache level.Returns false otherwise.
upgradeCore(index, n) 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.
upgradeLevel(index, n) Tries to upgrade the level of the specified Hacknet Node by n.Returns true if the Hacknet Nodes 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(index, n) Tries to upgrade the specified Hacknet Nodes RAM n times. Note that each upgrade doubles the Nodes RAM. So this is equivalent to multiplying the Nodes RAM by 2 n.Returns true if the Hacknet Nodes 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.