NETSCRIPT: allow getFunctionRamCost to get base RAM cost for scripts (#2771)

This commit is contained in:
Mathekatze
2026-05-17 03:37:58 +02:00
committed by GitHub
parent 6fcdb46888
commit 0257a37b9e
4 changed files with 33 additions and 6 deletions
+14 -2
View File
@@ -4,7 +4,9 @@
## NS.getFunctionRamCost() method
Get the ram cost of a netscript function.
Get the RAM cost of a netscript function.
The base RAM cost per script thread can also be retrieved by using `"baseCost"` as argument to this function.
**Signature:**
@@ -42,7 +44,7 @@ string
</td><td>
The fully-qualified function name, without the leading `ns`<!-- -->. Example inputs: `hack`<!-- -->, `tprint`<!-- -->, `stock.getPosition`<!-- -->.
The fully-qualified function name, without the leading `ns`<!-- -->.
</td></tr>
@@ -56,3 +58,13 @@ number
RAM cost: 0 GB
## Example
```js
const RAM_baseCost = ns.getFunctionRamCost('baseCost');
const RAM_for_hack = ns.getFunctionRamCost('hack');
const RAM_for_tprint = ns.getFunctionRamCost('tprint');
const RAM_for_stock_getPosition = ns.getFunctionRamCost('stock.getPosition');
```
+3 -1
View File
@@ -718,7 +718,9 @@ Get the metadata of a file.
</td><td>
Get the ram cost of a netscript function.
Get the RAM cost of a netscript function.
The base RAM cost per script thread can also be retrieved by using `"baseCost"` as argument to this function.
</td></tr>