mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-01-05 12:57:35 +01:00
Added getServerMaxRam and getServerUsedRam, deprecated getServerRam
This commit is contained in:
parent
9951c8b18f
commit
4d9439a007
15
doc/source/netscript/basicfunctions/getServerMaxRam.rst
Normal file
15
doc/source/netscript/basicfunctions/getServerMaxRam.rst
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
getServerMaxRam() Netscript Function
|
||||||
|
====================================
|
||||||
|
|
||||||
|
.. js:function:: getServerMaxRam(hostname)
|
||||||
|
|
||||||
|
:RAM cost: 0.05 GB
|
||||||
|
:param string hostname: Hostname of target server.
|
||||||
|
:returns: Total ram available on that server. In GB.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
.. code-block:: javascript
|
||||||
|
|
||||||
|
maxRam = getServerMaxRam("helios"); // returns: 16
|
||||||
|
print("helios has "+maxRam + "GB");
|
@ -3,6 +3,8 @@ getServerRam() Netscript Function
|
|||||||
|
|
||||||
.. js:function:: getServerRam(hostname)
|
.. js:function:: getServerRam(hostname)
|
||||||
|
|
||||||
|
.. warning:: This function is deprecated.
|
||||||
|
|
||||||
:RAM cost: 0.1 GB
|
:RAM cost: 0.1 GB
|
||||||
:param string hostname: Hostname of target server.
|
:param string hostname: Hostname of target server.
|
||||||
:returns: An array of 2 number, first number is the total RAM, second the
|
:returns: An array of 2 number, first number is the total RAM, second the
|
||||||
|
15
doc/source/netscript/basicfunctions/getServerUsedRam.rst
Normal file
15
doc/source/netscript/basicfunctions/getServerUsedRam.rst
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
getServerUsedRam() Netscript Function
|
||||||
|
=====================================
|
||||||
|
|
||||||
|
.. js:function:: getServerUsedRam(hostname)
|
||||||
|
|
||||||
|
:RAM cost: 0.05 GB
|
||||||
|
:param string hostname: Hostname of target server.
|
||||||
|
:returns: Used ram on that server. In GB.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
.. code-block:: javascript
|
||||||
|
|
||||||
|
usedRam = getServerUsedRam("harakiri-sushi"); // returns: 5.6
|
||||||
|
print("harakiri-sushi uses "+usedRam + "GB");
|
@ -54,7 +54,8 @@ This includes information such as function signatures, what they do, and their r
|
|||||||
getServerMinSecurityLevel() <basicfunctions/getServerMinSecurityLevel>
|
getServerMinSecurityLevel() <basicfunctions/getServerMinSecurityLevel>
|
||||||
getServerRequiredHackingLevel() <basicfunctions/getServerRequiredHackingLevel>
|
getServerRequiredHackingLevel() <basicfunctions/getServerRequiredHackingLevel>
|
||||||
getServerNumPortsRequired() <basicfunctions/getServerNumPortsRequired>
|
getServerNumPortsRequired() <basicfunctions/getServerNumPortsRequired>
|
||||||
getServerRam() <basicfunctions/getServerRam>
|
getServerMaxRam() <basicfunctions/getServerMaxRam>
|
||||||
|
getServerUsedRam() <basicfunctions/getServerUsedRam>
|
||||||
serverExists() <basicfunctions/serverExists>
|
serverExists() <basicfunctions/serverExists>
|
||||||
fileExists() <basicfunctions/fileExists>
|
fileExists() <basicfunctions/fileExists>
|
||||||
isRunning() <basicfunctions/isRunning>
|
isRunning() <basicfunctions/isRunning>
|
||||||
@ -90,3 +91,8 @@ This includes information such as function signatures, what they do, and their r
|
|||||||
wget() <basicfunctions/wget>
|
wget() <basicfunctions/wget>
|
||||||
getFavorToDonate() <basicfunctions/getFavorToDonate>
|
getFavorToDonate() <basicfunctions/getFavorToDonate>
|
||||||
flags() <basicfunctions/flags>
|
flags() <basicfunctions/flags>
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:caption: Deprecated:
|
||||||
|
|
||||||
|
getServerRam() <basicfunctions/getServerRam>
|
@ -23,6 +23,8 @@ export const RamCostConstants: IMap<number> = {
|
|||||||
ScriptGetHackingLevelRamCost: 0.05,
|
ScriptGetHackingLevelRamCost: 0.05,
|
||||||
ScriptGetMultipliersRamCost: 4.0,
|
ScriptGetMultipliersRamCost: 4.0,
|
||||||
ScriptGetServerRamCost: 0.1,
|
ScriptGetServerRamCost: 0.1,
|
||||||
|
ScriptGetServerMaxRam: 0.05,
|
||||||
|
ScriptGetServerUsedRam: 0.05,
|
||||||
ScriptFileExistsRamCost: 0.1,
|
ScriptFileExistsRamCost: 0.1,
|
||||||
ScriptIsRunningRamCost: 0.1,
|
ScriptIsRunningRamCost: 0.1,
|
||||||
ScriptHacknetNodesRamCost: 4.0,
|
ScriptHacknetNodesRamCost: 4.0,
|
||||||
@ -122,6 +124,8 @@ export const RamCosts: IMap<any> = {
|
|||||||
getServerGrowth: () => RamCostConstants.ScriptGetServerRamCost,
|
getServerGrowth: () => RamCostConstants.ScriptGetServerRamCost,
|
||||||
getServerNumPortsRequired: () => RamCostConstants.ScriptGetServerRamCost,
|
getServerNumPortsRequired: () => RamCostConstants.ScriptGetServerRamCost,
|
||||||
getServerRam: () => RamCostConstants.ScriptGetServerRamCost,
|
getServerRam: () => RamCostConstants.ScriptGetServerRamCost,
|
||||||
|
getServerMaxRam: () => RamCostConstants.ScriptGetServerMaxRam,
|
||||||
|
getServerUsedRam: () => RamCostConstants.ScriptGetServerUsedRam,
|
||||||
serverExists: () => RamCostConstants.ScriptGetServerRamCost,
|
serverExists: () => RamCostConstants.ScriptGetServerRamCost,
|
||||||
fileExists: () => RamCostConstants.ScriptFileExistsRamCost,
|
fileExists: () => RamCostConstants.ScriptFileExistsRamCost,
|
||||||
isRunning: () => RamCostConstants.ScriptIsRunningRamCost,
|
isRunning: () => RamCostConstants.ScriptIsRunningRamCost,
|
||||||
|
@ -1709,6 +1709,18 @@ function NetscriptFunctions(workerScript) {
|
|||||||
workerScript.log("getServerRam", `returned [${formatNumber(server.maxRam, 2)}GB, ${formatNumber(server.ramUsed, 2)}GB]`);
|
workerScript.log("getServerRam", `returned [${formatNumber(server.maxRam, 2)}GB, ${formatNumber(server.ramUsed, 2)}GB]`);
|
||||||
return [server.maxRam, server.ramUsed];
|
return [server.maxRam, server.ramUsed];
|
||||||
},
|
},
|
||||||
|
getServerMaxRam: function(ip) {
|
||||||
|
updateDynamicRam("getServerMaxRam", getRamCost("getServerMaxRam"));
|
||||||
|
const server = safeGetServer(ip, "getServerMaxRam");
|
||||||
|
workerScript.log("getServerMaxRam", `returned ${formatNumber(server.maxRam, 2)}GB`);
|
||||||
|
return server.maxRam;
|
||||||
|
},
|
||||||
|
getServerUsedRam: function(ip) {
|
||||||
|
updateDynamicRam("getServerUsedRam", getRamCost("getServerUsedRam"));
|
||||||
|
const server = safeGetServer(ip, "getServerUsedRam");
|
||||||
|
workerScript.log("getServerUsedRam", `returned ${formatNumber(server.ramUsed, 2)}GB`);
|
||||||
|
return server.ramUsed;
|
||||||
|
},
|
||||||
serverExists: function(ip) {
|
serverExists: function(ip) {
|
||||||
updateDynamicRam("serverExists", getRamCost("serverExists"));
|
updateDynamicRam("serverExists", getRamCost("serverExists"));
|
||||||
return (getServer(ip) !== null);
|
return (getServer(ip) !== null);
|
||||||
|
@ -394,6 +394,16 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function() {
|
|||||||
await testNonzeroDynamicRamCost(f);
|
await testNonzeroDynamicRamCost(f);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("getServerMaxRam()", async function() {
|
||||||
|
const f = ["getServerMaxRam"];
|
||||||
|
await testNonzeroDynamicRamCost(f);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("getServerUsedRam()", async function() {
|
||||||
|
const f = ["getServerUsedRam"];
|
||||||
|
await testNonzeroDynamicRamCost(f);
|
||||||
|
});
|
||||||
|
|
||||||
it("serverExists()", async function() {
|
it("serverExists()", async function() {
|
||||||
const f = ["serverExists"];
|
const f = ["serverExists"];
|
||||||
await testNonzeroDynamicRamCost(f);
|
await testNonzeroDynamicRamCost(f);
|
||||||
|
@ -284,6 +284,16 @@ describe("Netscript Static RAM Calculation/Generation Tests", function() {
|
|||||||
await expectNonZeroRamCost(f);
|
await expectNonZeroRamCost(f);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("getServerMaxRam()", async function() {
|
||||||
|
const f = ["getServerMaxRam"];
|
||||||
|
await expectNonZeroRamCost(f);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("getServerUsedRam()", async function() {
|
||||||
|
const f = ["getServerUsedRam"];
|
||||||
|
await expectNonZeroRamCost(f);
|
||||||
|
});
|
||||||
|
|
||||||
it("serverExists()", async function() {
|
it("serverExists()", async function() {
|
||||||
const f = ["serverExists"];
|
const f = ["serverExists"];
|
||||||
await expectNonZeroRamCost(f);
|
await expectNonZeroRamCost(f);
|
||||||
|
Loading…
Reference in New Issue
Block a user