2021-10-30 18:34:14 +02:00
|
|
|
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
|
|
|
2021-10-30 21:46:34 +02:00
|
|
|
[Home](./index.md) > [bitburner](./bitburner.md) > [Hacknet](./bitburner.hacknet.md) > [hashCost](./bitburner.hacknet.hashcost.md)
|
2021-10-30 18:34:14 +02:00
|
|
|
|
2021-10-30 21:46:34 +02:00
|
|
|
## Hacknet.hashCost() method
|
2021-10-30 18:34:14 +02:00
|
|
|
|
2021-11-03 05:27:21 +01:00
|
|
|
Get the cost of a hash upgrade.
|
2021-10-30 18:34:14 +02:00
|
|
|
|
|
|
|
<b>Signature:</b>
|
|
|
|
|
|
|
|
```typescript
|
2022-08-17 14:50:05 +02:00
|
|
|
hashCost(upgName: string, count?: number): number;
|
2021-10-30 18:34:14 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
|
|
|
| Parameter | Type | Description |
|
|
|
|
| --- | --- | --- |
|
2021-11-03 05:27:21 +01:00
|
|
|
| upgName | string | Name of the upgrade of Hacknet Node. |
|
2022-08-17 14:50:05 +02:00
|
|
|
| count | number | Number of upgrades to buy at once. Defaults to 1 if not specified. |
|
2021-10-30 18:34:14 +02:00
|
|
|
|
|
|
|
<b>Returns:</b>
|
|
|
|
|
|
|
|
number
|
|
|
|
|
|
|
|
Number of hashes required for the specified upgrade.
|
|
|
|
|
|
|
|
## Remarks
|
|
|
|
|
2021-10-30 21:46:34 +02:00
|
|
|
RAM cost: 0 GB
|
2021-10-30 18:34:14 +02:00
|
|
|
|
2021-11-03 05:27:21 +01:00
|
|
|
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.
|
|
|
|
|
2022-01-08 19:25:06 +01:00
|
|
|
## Example 1
|
2021-10-30 18:34:14 +02:00
|
|
|
|
|
|
|
|
2021-10-30 21:46:34 +02:00
|
|
|
```ts
|
2022-01-08 19:25:06 +01:00
|
|
|
// NS1:
|
2021-10-30 18:34:14 +02:00
|
|
|
var upgradeName = "Sell for Corporation Funds";
|
|
|
|
if (hacknet.numHashes() > hacknet.hashCost(upgradeName)) {
|
2022-04-13 07:35:35 +02:00
|
|
|
hacknet.spendHashes(upgradeName);
|
2021-10-30 18:34:14 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2022-01-08 19:25:06 +01:00
|
|
|
## Example 2
|
|
|
|
|
|
|
|
|
|
|
|
```ts
|
|
|
|
// NS2:
|
|
|
|
const upgradeName = "Sell for Corporation Funds";
|
|
|
|
if (ns.hacknet.numHashes() > ns.hacknet.hashCost(upgradeName)) {
|
2022-04-13 07:35:35 +02:00
|
|
|
ns.hacknet.spendHashes(upgradeName);
|
2022-01-08 19:25:06 +01:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|