Update netscript documentation.

Unfortunately, I haven't used most of the specialty APIs yet, so I'm not intimately familiar with where their documentation might be wrong. I figured some fixes were better than no fixes, and I can always make more fixes later.

Fixes #1023.
This commit is contained in:
MageKing17
2021-07-02 14:27:59 -07:00
committed by danielyxie
parent 55d1ebd0e4
commit ae15914efa
73 changed files with 322 additions and 267 deletions

View File

@@ -8,15 +8,18 @@ calculateExp() Netscript Function
:param number mult: Assume a specific skill multipler (not exp multiplier).
:returns: number of exp required to reach given ``skillLevel`` with that multiplier.
You must have Source-File 5-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
This function calculates the amount of experience needed to reach level the given ``skillLevel``.
This function calculates the amount of experience needed to reach the given
``skillLevel``.
Examples:
.. code-block:: javascript
nextHacking = getStats().hacking+1;
player = getPlayer();
nextHacking = player.hacking_skill+1;
nextExp = formulas.basic.calculateExp(nextHacking);
missingExp = nextExp - getCharacterInformation().hackingExp;
missingExp = nextExp - player.hacking_exp;
tprint("Missing " + missingExp + " to reach next hacking level");

View File

@@ -8,7 +8,8 @@ calculateSkill() Netscript Function
:param number mult: Assume a specific skill multipler (not exp multiplier).
:returns: skillLevel that ``exp`` would reach with that multiplier.
You must have Source-File 5-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
This function calculates the skillLevel that the given amount of ``exp`` would reach.

View File

@@ -7,17 +7,21 @@ growPercent() Netscript Function
:param server server: The server that receives the growth.
:param number threads: The number of thread that would be used.
:param player player: The player.
:returns: The percentage growth this server would receive with these parameters.
:returns: The amount the server's money would be multiplied by with these
parameters.
You must have Source-File 5-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function.
Player can be acquired with the :doc:`getPlayer<../../singularityfunctions/getPlayer>` function.
Player can be acquired with the :doc:`getPlayer<../../basicfunctions/getPlayer>` function.
This function calculates percentage of growth a server would receive with these parameters.
This function calculates the amount of growth, as a multiplier, a server
would receive with these parameters. Despite its name, it does not return
a percentage.
Examples:
.. code-block:: javascript
tprint(formulas.basic.growPercent(getServer(), 50, getPlayer()))
tprint(formulas.basic.growPercent(getServer(), 50, getPlayer()))

View File

@@ -8,10 +8,11 @@ growTime() Netscript Function
:param player player: The player.
:returns: The time it takes to grow this server. In seconds.
You must have Source-File 5-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function.
Player can be acquired with the :doc:`getPlayer<../../singularityfunctions/getPlayer>` function.
Player can be acquired with the :doc:`getPlayer<../../basicfunctions/getPlayer>` function.
This function calculates the amount of time it takes to grow a server.
@@ -21,4 +22,4 @@ growTime() Netscript Function
server = getServer();
server.hackDifficulty = server.minDifficulty;
tprint(formulas.basic.growTime(server, getPlayer()));
tprint(formulas.basic.growTime(server, getPlayer()));

View File

@@ -6,14 +6,15 @@ hackChance() Netscript Function
:RAM cost: 0 GB
:param server server: The server to hack.
:param player player: The player.
:returns: The change to hack that server. between 0 and 1.
:returns: The chance to hack that server, between 0 and 1.
You must have Source-File 5-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function.
Player can be acquired with the :doc:`getPlayer<../../singularityfunctions/getPlayer>` function.
Player can be acquired with the :doc:`getPlayer<../../basicfunctions/getPlayer>` function.
This function calculates percentage chance to hack a server.
This function calculates the probability to successfully hack a server.
Examples:
@@ -21,4 +22,4 @@ hackChance() Netscript Function
server = getServer();
server.hackDifficulty = server.minDifficulty;
tprint(formulas.basic.hackChance(server, getPlayer()));
tprint(formulas.basic.hackChance(server, getPlayer()));

View File

@@ -8,10 +8,11 @@ hackExp() Netscript Function
:param player player: The player.
:returns: The amount of exp that would be acquired if this server were to be hacked.
You must have Source-File 5-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function.
Player can be acquired with the :doc:`getPlayer<../../singularityfunctions/getPlayer>` function.
Player can be acquired with the :doc:`getPlayer<../../basicfunctions/getPlayer>` function.
This function calculates the amount of exp obtained by hacking a server.
@@ -19,6 +20,4 @@ hackExp() Netscript Function
.. code-block:: javascript
server = getServer();
server.hackDifficulty = 99.9;
tprint(formulas.basic.hackExp(server, getPlayer()));
tprint(formulas.basic.hackExp(getServer(), getPlayer()));

View File

@@ -6,14 +6,15 @@ hackPercent() Netscript Function
:RAM cost: 0 GB
:param server server: The server to hack.
:param player player: The player.
:returns: The percentage of money hacked from a servers maximum money.
:returns: The percentage of money hacked from the server's money.
You must have Source-File 5-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function.
Player can be acquired with the :doc:`getPlayer<../../singularityfunctions/getPlayer>` function.
Player can be acquired with the :doc:`getPlayer<../../basicfunctions/getPlayer>` function.
This function calculates the percentage of maximum money hacked from a server.
This function calculates the percentage of money hacked from a server.
Multiply this by thread count to know calculate the percentage for more than 1 thread.
Examples:
@@ -22,4 +23,4 @@ hackPercent() Netscript Function
server = getServer();
server.hackDifficulty = server.minDifficulty;
tprint(formulas.basic.hackPercent(server, getPlayer()));
tprint(formulas.basic.hackPercent(server, getPlayer()));

View File

@@ -8,10 +8,11 @@ hackTime() Netscript Function
:param player player: The player.
:returns: The time it takes to hack this server. In seconds.
You must have Source-File 5-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function.
Player can be acquired with the :doc:`getPlayer<../../singularityfunctions/getPlayer>` function.
Player can be acquired with the :doc:`getPlayer<../../basicfunctions/getPlayer>` function.
This function calculates the amount of time it takes to hack a server.
@@ -21,4 +22,4 @@ hackTime() Netscript Function
server = getServer();
server.hackDifficulty = server.minDifficulty;
tprint(formulas.basic.hackTime(server, getPlayer()));
tprint(formulas.basic.hackTime(server, getPlayer()));

View File

@@ -8,10 +8,11 @@ weakenTime() Netscript Function
:param player player: The player.
:returns: The time it takes to weaken this server. In seconds.
You must have Source-File 5-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function.
Player can be acquired with the :doc:`getPlayer<../../singularityfunctions/getPlayer>` function.
Player can be acquired with the :doc:`getPlayer<../../basicfunctions/getPlayer>` function.
This function calculates the amount of time it takes to weaken a server.
@@ -21,4 +22,4 @@ weakenTime() Netscript Function
server = getServer();
server.hackDifficulty = server.minDifficulty;
tprint(formulas.basic.weakenTime(server, getPlayer()));
tprint(formulas.basic.weakenTime(server, getPlayer()));

View File

@@ -6,21 +6,28 @@ constants() Netscript Function
:RAM cost: 0 GB
:returns: A structure with various constants related to hacknet nodes.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Returns an object with the following properties::
{
MoneyGainPerLevel: Multiplied by the node's level to get the node's base income
BaseCost: A multiplier used when buying new nodes or upgrading levels
LevelBaseCost: A multiplier used when upgrading levels
RamBaseCost: A multiplier used when upgrading RAM
CoreBaseCost: A multiplier used when buying additional cores
PurchaseNextMult: The root of an exponent used when buying new nodes
UpgradeLevelMult: The root of an exponent used when upgrading levels
UpgradeRamMult: The root of an exponent used when upgrading RAM
UpgradeCoreMult: The root of an exponent used when buying additional cores
MaxLevel: Maximum level a node can have
MaxRam: Maximum RAM a node can have
MaxCores: Maximum number of cores a node can have
}
Examples:
.. code-block:: javascript
{
MoneyGainPerLevel
BaseCost
LevelBaseCost
RamBaseCost
CoreBaseCost
PurchaseNextMult
UpgradeLevelMult
UpgradeRamMult
UpgradeCoreMult
MaxLevel
MaxRam
MaxCores
}
tprint("Maximum RAM a hacknet node can have: "+formulas.hacknetNodes.constants().MaxRam+" GB.");

View File

@@ -9,7 +9,8 @@ coreUpgradeCost() Netscript Function
:param number costMult: Aug multiplier that reduces cost. Defaults to ``1``.
:returns: Money required to go from ``startingCores`` to ``startingCores+extraCores``.
You must have Source-File 5-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
This function calculates the cost of upgrading cores from any level to any level.

View File

@@ -8,7 +8,8 @@ hacknetNodeCost() Netscript Function
:param number costMult: Aug multiplier that reduces cost. Defaults to ``1``.
:returns: Money required to buy your ``nodeN`` th node.
You must have Source-File 5-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
This function calculates the cost purchasing a hacknet node.

View File

@@ -9,7 +9,8 @@ levelUpgradeCost() Netscript Function
:param number costMult: Aug multiplier that reduces cost. Defaults to ``1``.
:returns: Money required to go from ``startingLevel`` to ``startingLevel+extraLevels``.
You must have Source-File 5-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
This function calculates the cost of upgrading levels from any level to any level.
@@ -17,4 +18,4 @@ levelUpgradeCost() Netscript Function
.. code-block:: javascript
formulas.hacknetNodes.levelUpgradeCost(1, 5); // returns: 2816
formulas.hacknetNodes.levelUpgradeCost(1, 5); // returns: 2816

View File

@@ -9,7 +9,8 @@ moneyGainRate() Netscript Function
:param number core: cores of the node.
:returns: Money per second that a node with those stats would gain per second.
You must have Source-File 5-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
This function calculates the money rate of a node with the given stats.
@@ -21,4 +22,4 @@ moneyGainRate() Netscript Function
currentRate = formulas.hacknetNodes.moneyGainRate(node.level, node.ram, node.cores);
levelRate = formulas.hacknetNodes.moneyGainRate(node.level+1, node.ram, node.cores);
ramRate = formulas.hacknetNodes.moneyGainRate(node.level, node.ram*2, node.cores);
coresRate = formulas.hacknetNodes.moneyGainRate(node.level, node.ram, node.cores+1);
coresRate = formulas.hacknetNodes.moneyGainRate(node.level, node.ram, node.cores+1);

View File

@@ -11,7 +11,8 @@ ramUpgradeCost() Netscript Function
..note:: ``startingRam`` is the actual amount of ram, not the amount of levels of ram.
You must have Source-File 5-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
This function calculates the cost of upgrading levels from any level to any level.
@@ -19,4 +20,4 @@ ramUpgradeCost() Netscript Function
.. code-block:: javascript
formulas.hacknetNodes.ramUpgradeCost(1, 5); // returns: 2095000
formulas.hacknetNodes.ramUpgradeCost(1, 5); // returns: 2095000

View File

@@ -9,7 +9,9 @@ cacheUpgradeCost() Netscript Function
:param number costMult: Aug multiplier that reduces cost. Defaults to ``1``.
:returns: Money required to go from ``startingLevel`` to ``startingLevel+extraLevels``.
You must have Source-File 5-1 and Source-File 9-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
This function calculates the cost of upgrading cache from any level to any level.

View File

@@ -6,24 +6,32 @@ constants() Netscript Function
:RAM cost: 0 GB
:returns: A structure with various constants related to hacknet servers.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
Returns an object with the following properties::
{
HashesPerLevel: Multiplied by the server's level to get the server's base income
BaseCost: A multiplier used when buying new nodes or upgrading levels
RamBaseCost: A multiplier used when upgrading RAM
CoreBaseCost: A multiplier used when buying additional cores
CacheBaseCost: A multiplier used when upgrading cache
PurchaseMult: The root of an exponent used when buying new servers
UpgradeLevelMult: The root of an exponent used when upgrading levels
UpgradeRamMult: The root of an exponent used when upgrading RAM
UpgradeCoreMult: The root of an exponent used when buying additional cores
UpgradeCacheMult: The root of an exponent used when upgrading cache
MaxServers: Maximum number of hacknet servers you can own
MaxLevel: Maximum level a server can have
MaxRam: Maximum RAM a server can have
MaxCores: Maximum number of cores a server can have
MaxCache: Maximum cache a server can have
}
Examples:
.. code-block:: javascript
{
HashesPerLevel
BaseCost
RamBaseCost
CoreBaseCost
CacheBaseCost
PurchaseMult
UpgradeLevelMult
UpgradeRamMult
UpgradeCoreMult
UpgradeCacheMult
MaxServers
MaxLevel
MaxRam
MaxCores
MaxCache
}
tprint("Maximum RAM a hacknet server can have: "+formulas.hacknetServers.constants().MaxRam+" GB");

View File

@@ -9,7 +9,9 @@ coreUpgradeCost() Netscript Function
:param number costMult: Aug multiplier that reduces cost. Defaults to ``1``.
:returns: Money required to go from ``startingCores`` to ``startingCores+extraCores``.
You must have Source-File 5-1 and Source-File 9-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
This function calculates the cost of upgrading cores from any level to any level.

View File

@@ -8,7 +8,9 @@ hacknetServerCost() Netscript Function
:param number costMult: Aug multiplier that reduces cost. Defaults to ``1``.
:returns: Money required to buy your ``serverN`` th node.
You must have Source-File 5-1 and Source-File 9-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
This function calculates the cost purchasing a hacknet node.

View File

@@ -10,7 +10,9 @@ hashGainRate() Netscript Function
:param number core: cores of the server.
:returns: Money per second that a server with those stats would gain per second.
You must have Source-File 5-1 and Source-File 9-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
This function calculates the hash rate of a server with the given stats.
@@ -19,7 +21,7 @@ hashGainRate() Netscript Function
.. code-block:: javascript
server = hacknet.getNodeStats(1);
currentRate = formulas.hacknetNodes.hashGainRate(server.level, 0, server.ram, server.cores);
levelRate = formulas.hacknetNodes.hashGainRate(server.level+1, 0, server.ram, server.cores);
ramRate = formulas.hacknetNodes.hashGainRate(server.level, 0, server.ram*2, server.cores);
coresRate = formulas.hacknetNodes.hashGainRate(server.level, 0, server.ram, server.cores+1);
currentRate = formulas.hacknetServers.hashGainRate(server.level, 0, server.ram, server.cores);
levelRate = formulas.hacknetServers.hashGainRate(server.level+1, 0, server.ram, server.cores);
ramRate = formulas.hacknetServers.hashGainRate(server.level, 0, server.ram*2, server.cores);
coresRate = formulas.hacknetServers.hashGainRate(server.level, 0, server.ram, server.cores+1);

View File

@@ -8,7 +8,9 @@ hashUpgradeCost() Netscript Function
:param number level: Level of the upgrade.
:returns: Amount of Hash.
You must have Source-File 5-1 and Source-File 9-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
This function calculates amount of Hash require to buy level ``level`` of upgrade ``upgName``.

View File

@@ -9,7 +9,9 @@ levelUpgradeCost() Netscript Function
:param number costMult: Aug multiplier that reduces cost. Defaults to ``1``.
:returns: Money required to go from ``startingLevel`` to ``startingLevel+extraLevels``.
You must have Source-File 5-1 and Source-File 9-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
This function calculates the cost of upgrading levels from any level to any level.
@@ -17,4 +19,4 @@ levelUpgradeCost() Netscript Function
.. code-block:: javascript
formulas.hacknetServers.levelUpgradeCost(1, 5); // returns: 2792000
formulas.hacknetServers.levelUpgradeCost(1, 5); // returns: 2792000

View File

@@ -11,7 +11,9 @@ ramUpgradeCost() Netscript Function
..note:: ``startingRam`` is the actual amount of ram, not the amount of levels of ram.
You must have Source-File 5-1 and Source-File 9-1 in order to use this function.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
This function calculates the cost of upgrading levels from any level to any level.
@@ -19,4 +21,4 @@ ramUpgradeCost() Netscript Function
.. code-block:: javascript
formulas.hacknetServers.ramUpgradeCost(1, 5); // returns: 15810000
formulas.hacknetServers.ramUpgradeCost(1, 5); // returns: 15810000