mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
91 lines
1.3 KiB
Markdown
91 lines
1.3 KiB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
|
|
[Home](./index.md) > [bitburner](./bitburner.md) > [Hacknet](./bitburner.hacknet.md) > [hashCost](./bitburner.hacknet.hashcost.md)
|
|
|
|
## Hacknet.hashCost() method
|
|
|
|
Get the cost of a hash upgrade.
|
|
|
|
**Signature:**
|
|
|
|
```typescript
|
|
hashCost(upgName: HacknetServerHashUpgrade, count?: number): number;
|
|
```
|
|
|
|
## Parameters
|
|
|
|
<table><thead><tr><th>
|
|
|
|
Parameter
|
|
|
|
|
|
</th><th>
|
|
|
|
Type
|
|
|
|
|
|
</th><th>
|
|
|
|
Description
|
|
|
|
|
|
</th></tr></thead>
|
|
<tbody><tr><td>
|
|
|
|
upgName
|
|
|
|
|
|
</td><td>
|
|
|
|
[HacknetServerHashUpgrade](./bitburner.hacknetserverhashupgrade.md)
|
|
|
|
|
|
</td><td>
|
|
|
|
Name of the upgrade using hash of Hacknet Server.
|
|
|
|
|
|
</td></tr>
|
|
<tr><td>
|
|
|
|
count
|
|
|
|
|
|
</td><td>
|
|
|
|
number
|
|
|
|
|
|
</td><td>
|
|
|
|
_(Optional)_ Number of upgrades to buy at once. Defaults to 1 if not specified.
|
|
|
|
|
|
</td></tr>
|
|
</tbody></table>
|
|
|
|
**Returns:**
|
|
|
|
number
|
|
|
|
Number of hashes required for the specified upgrade.
|
|
|
|
## Remarks
|
|
|
|
RAM cost: 0.5 GB
|
|
|
|
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.
|
|
|
|
## Example
|
|
|
|
|
|
```js
|
|
const upgradeName = "Sell for Corporation Funds";
|
|
if (ns.hacknet.numHashes() > ns.hacknet.hashCost(upgradeName)) {
|
|
ns.hacknet.spendHashes(upgradeName);
|
|
}
|
|
```
|
|
|