From 2ce6ff2041e72bf8e37be331adc93137967ce65e Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Fri, 12 Mar 2021 02:51:56 -0500 Subject: [PATCH] work to make documentation unified. --- .../getBitNodeMultipliers.rst | 21 ++- .../netscript/basicfunctions/brutessh.rst | 12 +- doc/source/netscript/basicfunctions/clear.rst | 11 +- .../netscript/basicfunctions/clearLog.rst | 11 +- .../netscript/basicfunctions/deleteServer.rst | 12 +- .../netscript/basicfunctions/disableLog.rst | 9 +- .../netscript/basicfunctions/enableLog.rst | 10 +- doc/source/netscript/basicfunctions/exec.rst | 42 ++--- doc/source/netscript/basicfunctions/exit.rst | 2 +- .../netscript/basicfunctions/fileExists.rst | 34 ++-- .../netscript/basicfunctions/ftpcrack.rst | 13 +- .../basicfunctions/getFavorToDonate.rst | 7 +- .../netscript/basicfunctions/getGrowTime.rst | 24 ++- .../netscript/basicfunctions/getHackTime.rst | 18 +- .../basicfunctions/getHackingLevel.rst | 7 +- .../basicfunctions/getHackingMultipliers.rst | 10 +- .../basicfunctions/getHacknetMultipliers.rst | 10 +- .../netscript/basicfunctions/getHostname.rst | 8 +- .../basicfunctions/getPortHandle.rst | 4 +- .../basicfunctions/getPurchasedServerCost.rst | 9 +- .../getPurchasedServerLimit.rst | 7 +- .../getPurchasedServerMaxRam.rst | 7 +- .../basicfunctions/getPurchasedServers.rst | 12 +- .../basicfunctions/getScriptExpGain.rst | 18 +- .../basicfunctions/getScriptIncome.rst | 19 ++- .../basicfunctions/getScriptLogs.rst | 28 +-- .../basicfunctions/getScriptName.rst | 7 +- .../netscript/basicfunctions/getScriptRam.rst | 15 +- .../getServerBaseSecurityLevel.rst | 28 ++- .../basicfunctions/getServerGrowth.rst | 19 ++- .../basicfunctions/getServerMaxMoney.rst | 11 +- .../getServerMinSecurityLevel.rst | 11 +- .../getServerMoneyAvailable.rst | 18 +- .../getServerNumPortsRequired.rst | 12 +- .../netscript/basicfunctions/getServerRam.rst | 12 +- .../getServerRequiredHackingLevel.rst | 11 +- .../basicfunctions/getServerSecurityLevel.rst | 12 +- .../basicfunctions/getTimeSinceLastAug.rst | 7 +- .../basicfunctions/getWeakenTime.rst | 17 +- doc/source/netscript/basicfunctions/grow.rst | 34 ++-- .../basicfunctions/growthAnalyze.rst | 25 ++- doc/source/netscript/basicfunctions/hack.rst | 28 +-- .../basicfunctions/hackAnalyzePercent.rst | 20 ++- .../basicfunctions/hackAnalyzeThreads.rst | 22 ++- .../netscript/basicfunctions/hackChance.rst | 15 +- .../basicfunctions/hasRootAccess.rst | 9 +- .../netscript/basicfunctions/httpworm.rst | 11 +- .../netscript/basicfunctions/isLogEnabled.rst | 12 +- .../netscript/basicfunctions/isRunning.rst | 41 +++-- doc/source/netscript/basicfunctions/kill.rst | 48 +++--- .../netscript/basicfunctions/killall.rst | 15 +- doc/source/netscript/basicfunctions/ls.rst | 14 +- .../netscript/basicfunctions/nFormat.rst | 22 +-- doc/source/netscript/basicfunctions/nuke.rst | 9 +- doc/source/netscript/basicfunctions/peek.rst | 8 +- doc/source/netscript/basicfunctions/print.rst | 8 +- .../netscript/basicfunctions/prompt.rst | 19 ++- doc/source/netscript/basicfunctions/ps.rst | 33 ++-- .../basicfunctions/purchaseServer.rst | 26 +-- doc/source/netscript/basicfunctions/read.rst | 21 ++- .../netscript/basicfunctions/relaysmtp.rst | 12 +- doc/source/netscript/basicfunctions/rm.rst | 12 +- doc/source/netscript/basicfunctions/run.rst | 48 +++--- doc/source/netscript/basicfunctions/scan.rst | 14 +- doc/source/netscript/basicfunctions/scp.rst | 34 ++-- .../netscript/basicfunctions/scriptKill.rst | 17 +- .../basicfunctions/scriptRunning.rst | 26 +-- .../netscript/basicfunctions/serverExists.rst | 11 +- doc/source/netscript/basicfunctions/sleep.rst | 9 +- doc/source/netscript/basicfunctions/spawn.rst | 22 ++- .../netscript/basicfunctions/sqlinject.rst | 11 +- doc/source/netscript/basicfunctions/tail.rst | 18 +- .../netscript/basicfunctions/tprint.rst | 10 +- .../netscript/basicfunctions/tryWrite.rst | 10 +- .../netscript/basicfunctions/weaken.rst | 27 +-- doc/source/netscript/basicfunctions/wget.rst | 14 +- doc/source/netscript/basicfunctions/write.rst | 27 +-- .../bladeburnerapi/getActionAutolevel.rst | 8 +- .../getActionCountRemaining.rst | 16 +- .../bladeburnerapi/getActionCurrentLevel.rst | 10 +- .../getActionEstimatedSuccessChance.rst | 10 +- .../bladeburnerapi/getActionMaxLevel.rst | 8 +- .../bladeburnerapi/getActionRepGain.rst | 14 +- .../bladeburnerapi/getActionTime.rst | 9 +- .../bladeburnerapi/getBlackOpNames.rst | 7 +- .../bladeburnerapi/getBlackOpRank.rst | 8 +- .../netscript/bladeburnerapi/getBonusTime.rst | 9 +- .../netscript/bladeburnerapi/getCity.rst | 7 +- .../netscript/bladeburnerapi/getCityChaos.rst | 8 +- .../getCityEstimatedCommunities.rst | 10 +- .../getCityEstimatedPopulation.rst | 10 +- .../bladeburnerapi/getContractNames.rst | 7 +- .../bladeburnerapi/getCurrentAction.rst | 11 +- .../bladeburnerapi/getGeneralActionNames.rst | 7 +- .../bladeburnerapi/getOperationNames.rst | 7 +- .../netscript/bladeburnerapi/getRank.rst | 7 +- .../bladeburnerapi/getSkillLevel.rst | 10 +- .../bladeburnerapi/getSkillNames.rst | 7 +- .../bladeburnerapi/getSkillPoints.rst | 7 +- .../bladeburnerapi/getSkillUpgradeCost.rst | 11 +- .../netscript/bladeburnerapi/getStamina.rst | 13 +- .../netscript/bladeburnerapi/getTeamSize.rst | 12 +- .../joinBladeburnerDivision.rst | 9 +- .../bladeburnerapi/joinBladeburnerFaction.rst | 9 +- .../bladeburnerapi/setActionAutolevel.rst | 7 +- .../bladeburnerapi/setActionLevel.rst | 7 +- .../netscript/bladeburnerapi/setTeamSize.rst | 8 +- .../netscript/bladeburnerapi/startAction.rst | 11 +- .../bladeburnerapi/stopBladeburnerAction.rst | 6 + .../netscript/bladeburnerapi/switchCity.rst | 8 +- .../netscript/bladeburnerapi/upgradeSkill.rst | 11 +- .../netscript/codingcontractapi/attempt.rst | 21 ++- .../codingcontractapi/getContractType.rst | 24 +-- .../netscript/codingcontractapi/getData.rst | 18 +- .../codingcontractapi/getDescription.rst | 22 ++- .../getNumTriesRemaining.rst | 16 +- doc/source/netscript/gangapi/ascendMember.rst | 6 +- .../netscript/gangapi/canRecruitMember.rst | 3 +- doc/source/netscript/gangapi/getBonusTime.rst | 4 +- .../netscript/gangapi/getChanceToWinClash.rst | 6 +- .../netscript/gangapi/getEquipmentCost.rst | 8 +- .../netscript/gangapi/getEquipmentNames.rst | 2 +- .../netscript/gangapi/getEquipmentStats.rst | 14 +- .../netscript/gangapi/getEquipmentType.rst | 4 +- .../netscript/gangapi/getGangInformation.rst | 5 +- .../gangapi/getMemberInformation.rst | 6 +- .../netscript/gangapi/getMemberNames.rst | 5 +- .../gangapi/getOtherGangInformation.rst | 5 +- doc/source/netscript/gangapi/getTaskNames.rst | 5 +- doc/source/netscript/gangapi/getTaskStats.rst | 52 +++--- .../netscript/gangapi/purchaseEquipment.rst | 4 +- .../netscript/gangapi/recruitMember.rst | 4 +- .../netscript/gangapi/setMemberTask.rst | 3 +- .../netscript/gangapi/setTerritoryWarfare.rst | 1 - .../hacknetnodeapi/getCacheUpgradeCost.rst | 12 +- .../hacknetnodeapi/getCoreUpgradeCost.rst | 10 +- .../hacknetnodeapi/getLevelUpgradeCost.rst | 10 +- .../netscript/hacknetnodeapi/getNodeStats.rst | 10 +- .../hacknetnodeapi/getPurchaseNodeCost.rst | 3 +- .../hacknetnodeapi/getRamUpgradeCost.rst | 12 +- .../netscript/hacknetnodeapi/hashCost.rst | 8 +- .../netscript/hacknetnodeapi/maxNumNodes.rst | 5 +- .../netscript/hacknetnodeapi/numHashes.rst | 2 +- .../netscript/hacknetnodeapi/numNodes.rst | 3 +- .../netscript/hacknetnodeapi/purchaseNode.rst | 6 +- .../netscript/hacknetnodeapi/spendHashes.rst | 12 +- .../netscript/hacknetnodeapi/upgradeCache.rst | 11 +- .../netscript/hacknetnodeapi/upgradeCore.rst | 11 +- .../netscript/hacknetnodeapi/upgradeLevel.rst | 9 +- .../netscript/hacknetnodeapi/upgradeRam.rst | 17 +- doc/source/netscript/netscriptgangapi.rst | 2 + .../netscript/netscripthacknetnodeapi.rst | 1 + .../netscriptsingularityfunctions.rst | 3 + .../singularityfunctions/applyToCompany.rst | 7 +- .../checkFactionInvitations.rst | 2 +- .../singularityfunctions/commitCrime.rst | 5 +- .../singularityfunctions/createProgram.rst | 4 +- .../singularityfunctions/donateToFaction.rst | 5 +- .../getAugmentationCost.rst | 5 +- doc/source/netscript/tixapi/buyStock.rst | 3 +- doc/source/netscript/tixapi/cancelOrder.rst | 2 +- .../netscript/tixapi/getStockAskPrice.rst | 3 +- .../netscript/tixapi/getStockBidPrice.rst | 3 +- .../netscript/tixapi/getStockForecast.rst | 3 +- .../netscript/tixapi/getStockMaxShares.rst | 3 +- .../netscript/tixapi/getStockPosition.rst | 3 +- doc/source/netscript/tixapi/getStockPrice.rst | 3 +- .../netscript/tixapi/getStockPurchaseCost.rst | 5 +- .../netscript/tixapi/getStockSaleGain.rst | 5 +- .../netscript/tixapi/getStockVolatility.rst | 3 +- doc/source/netscript/tixapi/placeOrder.rst | 2 +- doc/source/netscript/tixapi/sellShort.rst | 3 +- doc/source/netscript/tixapi/sellStock.rst | 3 +- doc/source/netscript/tixapi/shortStock.rst | 3 +- src/Bladeburner.js | 159 ++++++------------ src/Netscript/WorkerScript.ts | 6 +- 176 files changed, 1325 insertions(+), 916 deletions(-) diff --git a/doc/source/netscript/advancedfunctions/getBitNodeMultipliers.rst b/doc/source/netscript/advancedfunctions/getBitNodeMultipliers.rst index 4ed8b1e9b..ab8deac84 100644 --- a/doc/source/netscript/advancedfunctions/getBitNodeMultipliers.rst +++ b/doc/source/netscript/advancedfunctions/getBitNodeMultipliers.rst @@ -3,14 +3,19 @@ getBitNodeMultipliers() Netscript Function .. js:function:: getBitNodeMultipliers() - Returns an object containing the current BitNode multipliers. This function requires Source-File 5 in order - to run. The multipliers are returned in decimal forms (e.g. 1.5 instead of 150%). The multipliers represent - the difference between the current BitNode and the original BitNode (BitNode-1). For example, if the - *CrimeMoney* multiplier has a value of 0.1, then that means that committing crimes in the current BitNode - will only give 10% of the money you would have received in BitNode-1. + :RAM cost: 4 GB - The structure of the returned object is subject to change as BitNode multipliers get added to the game. - Refer to the `source code here `_ + Returns an object containing the current BitNode multipliers. This function + requires Source-File 5 in order to run. The multipliers are returned in + decimal forms (e.g. 1.5 instead of 150%). The multipliers represent the + difference between the current BitNode and the original BitNode (BitNode-1). + For example, if the *CrimeMoney* multiplier has a value of 0.1, then that + means that committing crimes in the current BitNode will only give 10% of + the money you would have received in BitNode-1. + + The structure of the returned object is subject to change as BitNode + multipliers get added to the game. Refer to the `source code here + `_ to see the name of the BitNode multipliers. Example:: @@ -18,5 +23,3 @@ getBitNodeMultipliers() Netscript Function mults = getBitNodeMultipliers(); print(mults.ServerMaxMoney); print(mults.HackExpGain); - - :RAM cost: 4 GB diff --git a/doc/source/netscript/basicfunctions/brutessh.rst b/doc/source/netscript/basicfunctions/brutessh.rst index b1803b3f1..4bd535fe4 100644 --- a/doc/source/netscript/basicfunctions/brutessh.rst +++ b/doc/source/netscript/basicfunctions/brutessh.rst @@ -1,13 +1,17 @@ brutessh() Netscript Function ============================= -.. js:function:: brutessh(hostname/ip) +.. js:function:: brutessh(hostname) - :param string hostname/ip: IP or hostname of the target server :RAM cost: 0.05 GB - Runs the BruteSSH.exe program on the target server. BruteSSH.exe must exist on your home computer. + :param string hostname: Hostname of the target server. - Example:: + Runs the BruteSSH.exe program on the target server. BruteSSH.exe must exist + on your home computer. + + Examples: + + .. code-block:: javascript brutessh("foodnstuff"); diff --git a/doc/source/netscript/basicfunctions/clear.rst b/doc/source/netscript/basicfunctions/clear.rst index 90cfee85c..3f4f7fd09 100644 --- a/doc/source/netscript/basicfunctions/clear.rst +++ b/doc/source/netscript/basicfunctions/clear.rst @@ -1,13 +1,16 @@ clear() Netscript Function ========================== -.. js:function:: clear(port/fn) +.. js:function:: clear(portOrFilename) - :param string/number port/fn: Port or text file to clear :RAM cost: 1 GB + :param string/number portOrFilename: Port or text file to clear. + This function is used to clear data in a :ref:`Netscript Port ` or a text file. - If the *port/fn* argument is a number between 1 and 20, then it specifies a port and will clear it (deleting all data from the underlying queue). + If the ``portOrFilename`` argument is a number between 1 and 20, then it + specifies a port and will clear it (deleting all data from the underlying queue). - If the *port/fn* argument is a string, then it specifies the name of a text file (.txt) and will delete all data from that text file. + If the ``portOrFilename`` argument is a string, then it specifies the name + of a text file (.txt) and will delete all data from that text file. diff --git a/doc/source/netscript/basicfunctions/clearLog.rst b/doc/source/netscript/basicfunctions/clearLog.rst index 96bcc694f..1c892b669 100644 --- a/doc/source/netscript/basicfunctions/clearLog.rst +++ b/doc/source/netscript/basicfunctions/clearLog.rst @@ -5,4 +5,13 @@ clearLog() Netscript Function :RAM cost: 0 GB - Clears the script's logs + Clears the script's logs. Useful when making monitoring scripts. + + Examples: + + .. code-block:: javascript + + while(true) { + clearLog(); + print(getServerMoneyAvailable('foodnstuff')); + } diff --git a/doc/source/netscript/basicfunctions/deleteServer.rst b/doc/source/netscript/basicfunctions/deleteServer.rst index e1c400f62..bb073904e 100644 --- a/doc/source/netscript/basicfunctions/deleteServer.rst +++ b/doc/source/netscript/basicfunctions/deleteServer.rst @@ -3,12 +3,12 @@ deleteServer() Netscript Function .. js:function:: deleteServer(hostname) - :param string hostname: Hostname of the server to delete :RAM cost: 2.25 GB + :param string hostname: Hostname of the server to delete. + :returns: ``true`` if successful, ``false`` otherwise. - Deletes one of your purchased servers, which is specified by its hostname. + Deletes the specified purchased server. - The *hostname* argument can be any data type, but it will be converted to a string. Whitespace is automatically removed from - the string. This function will not delete a server that still has scripts running on it. - - Returns true if successful, and false otherwise. + The ``hostname`` argument can be any data type, but it will be converted to + a string. Whitespace is automatically removed from the string. This function + will not delete a server that still has scripts running on it. diff --git a/doc/source/netscript/basicfunctions/disableLog.rst b/doc/source/netscript/basicfunctions/disableLog.rst index dba73c24d..e3b0a393a 100644 --- a/doc/source/netscript/basicfunctions/disableLog.rst +++ b/doc/source/netscript/basicfunctions/disableLog.rst @@ -1,16 +1,17 @@ disableLog() Netscript Function =============================== -.. js:function:: disableLog(fn) +.. js:function:: disableLog(functionName) - :param string fn: Name of function for which to disable logging :RAM cost: 0 GB + :param string functionName: Name of function for which to disable logging. + Disables logging for the given function. Logging can be disabled for all functions by passing 'ALL' as the argument. Note that this does not completely remove all logging functionality. - This only stops a function from logging - when the function is successful. If the function fails, it will still log the reason for failure. + This only stops a function from logging when the function is successful. If + the function fails, it will still log the reason for failure. Notable functions that cannot have their logs disabled: run, exec, exit diff --git a/doc/source/netscript/basicfunctions/enableLog.rst b/doc/source/netscript/basicfunctions/enableLog.rst index 691b9f133..60b3f5606 100644 --- a/doc/source/netscript/basicfunctions/enableLog.rst +++ b/doc/source/netscript/basicfunctions/enableLog.rst @@ -1,10 +1,12 @@ enableLog() Netscript Function ============================== -.. js:function:: enableLog(fn) +.. js:function:: enableLog(functionName) - :param string fn: Name of function for which to enable logging :RAM cost: 0 GB - Re-enables logging for the given function. If 'ALL' is passed into this function - as an argument, then it will revert the effects of disableLog('ALL') + :param string functionName: Name of function for which to enable logging. + + Re-enables logging for the given function. If 'ALL' is passed into this + function as an argument, then it will revert the effects of + ``disableLog('ALL')`` diff --git a/doc/source/netscript/basicfunctions/exec.rst b/doc/source/netscript/basicfunctions/exec.rst index 9ded031b2..d3ee7f011 100644 --- a/doc/source/netscript/basicfunctions/exec.rst +++ b/doc/source/netscript/basicfunctions/exec.rst @@ -1,39 +1,41 @@ exec() Netscript Function ========================= -.. js:function:: exec(script, hostname/ip, [numThreads=1], [args...]) +.. js:function:: exec(script, hostname[, numThreads=1[, args...]]) - :param string script: Filename of script to execute - :param string hostname/ip: IP or hostname of the 'target server' on which to execute the script - :param number numThreads: Optional thread count for new script. Set to 1 by default. Will be rounded to nearest integer - :param args...: - Additional arguments to pass into the new script that is being run. Note that if any arguments are being - passed into the new script, then the third argument *numThreads* must be filled in with a value. :RAM cost: 1.3 GB - Run a script as a separate process on a specified server. This is similar to the *run* function except - that it can be used to run a script on any server, instead of just the current server. + :param string script: Filename of script to execute. + :param string hostname: Hostname of the target server on which to execute the script. + :param number numThreads: Optional thread count for new script. Set to 1 by + default. Will be rounded to nearest integer + :param args...: Additional arguments to pass into the new script that is + being run. Note that if any arguments are being + passed into the new script, then the third argument ``numThreads`` must + be filled in with a value. + :returns: Newly created process id on success, 0 on failure. - If the script was successfully started, then this functions returns the PID - of that script. Otherwise, it returns 0. + Run a script as a separate process on a specified server. This is similar to + the :doc:`run` function except that it can be used to run a script on any + server, instead of just the current server. - .. note:: PID stands for Process ID. The PID is a unique identifier for each script. - The PID will always be a positive integer. - - .. warning:: Running this function with a *numThreads* argument of 0 will return 0 without + .. warning:: Running this function with a ``numThreads`` argument of 0 will return 0 without running the script. However, running this function with a negative *numThreads* argument will cause a runtime error. - The simplest way to use the *exec* command is to call it with just the script name and the target server. - The following example will try to run *generic-hack.script* on the *foodnstuff* server:: + The simplest way to use the :doc:`exec` command is to call it with + just the script name and the target server. The following example will try + to run ``generic-hack.script`` on the ``foodnstuff`` server:: exec("generic-hack.script", "foodnstuff"); - The following example will try to run the script *generic-hack.script* on the *joesguns* server with 10 threads:: + The following example will try to run the script ``generic-hack.script`` on + the ``joesguns`` server with 10 threads:: exec("generic-hack.script", "joesguns", 10); - This last example will try to run the script *foo.script* on the *foodnstuff* server with 5 threads. It will also pass - the number 1 and the string "test" in as arguments to the script:: + This last example will try to run the script ``foo.script`` on the + ``foodnstuff`` server with 5 threads. It will also pass the number 1 and the + string "test" in as arguments to the script:: exec("foo.script", "foodnstuff", 5, 1, "test"); diff --git a/doc/source/netscript/basicfunctions/exit.rst b/doc/source/netscript/basicfunctions/exit.rst index 64b8f4c44..d0b6094a4 100644 --- a/doc/source/netscript/basicfunctions/exit.rst +++ b/doc/source/netscript/basicfunctions/exit.rst @@ -5,4 +5,4 @@ exit() Netscript Function :RAM cost: 0 GB - Terminates the current script immediately + Terminates the current script immediately. diff --git a/doc/source/netscript/basicfunctions/fileExists.rst b/doc/source/netscript/basicfunctions/fileExists.rst index a14478a94..eda1c686c 100644 --- a/doc/source/netscript/basicfunctions/fileExists.rst +++ b/doc/source/netscript/basicfunctions/fileExists.rst @@ -1,25 +1,29 @@ fileExists() Netscript Function =============================== -.. js:function:: fileExists(filename, [hostname/ip]) +.. js:function:: fileExists(filename[, hostname]) - :param string filename: Filename of file to check - :param string hostname/ip: - Hostname or IP of target server. This is optional. If it is not specified then the - function will use the current server as the target server :RAM cost: 0.1 GB - Returns a boolean indicating whether the specified file exists on the target server. The filename - for scripts is case-sensitive, but for other types of files it is not. For example, *fileExists("brutessh.exe")* - will work fine, even though the actual program is named "BruteSSH.exe". + :param string filename: Filename of file to check. + :param string hostname: + Hostname of target server. This is optional. If it is not specified then + the function will use the current server as the target server. + :returns: ``true`` if the file exists, ``false`` if it doesn't. - If the *hostname/ip* argument is omitted, then the function will search through the current server (the server - running the script that calls this function) for the file. + The filename for scripts is case-sensitive, but for other types of files it + is not. For example, ``fileExists("brutessh.exe")`` will work fine, even + though the actual program is named ``BruteSSH.exe``. - Examples:: + If the ``hostname`` argument is omitted, then the function will search + through the server running the script that calls this function for the file. - fileExists("foo.script", "foodnstuff"); - fileExists("ftpcrack.exe"); + Examples: - The first example above will return true if the script named *foo.script* exists on the *foodnstuff* server, and false otherwise. - The second example above will return true if the current server contains the *FTPCrack.exe* program, and false otherwise. + .. code-block:: javascript + + fileExists("foo.script", "foodnstuff"); // returns: false + fileExists("ftpcrack.exe"); // returns: true + + The first example above will return true if the script named ``foo.script`` exists on the ``foodnstuff`` server, and false otherwise. + The second example above will return true if the current server contains the ``FTPCrack.exe`` program, and false otherwise. diff --git a/doc/source/netscript/basicfunctions/ftpcrack.rst b/doc/source/netscript/basicfunctions/ftpcrack.rst index 099a6c54e..1391934e9 100644 --- a/doc/source/netscript/basicfunctions/ftpcrack.rst +++ b/doc/source/netscript/basicfunctions/ftpcrack.rst @@ -1,13 +1,18 @@ ftpcrack() Netscript Function ============================= -.. js:function:: ftpcrack(hostname/ip) +.. js:function:: ftpcrack(hostname) - :param string hostname/ip: IP or hostname of the target server :RAM cost: 0.05 GB - Runs the FTPCrack.exe program on the target server. FTPCrack.exe must exist on your home computer. + :param string hostname: Hostname of the target server. - Example:: + Runs the ``FTPCrack.exe`` program on the target server. ``FTPCrack.exe`` + must exist on your home computer. + + + Examples: + + .. code-block:: javascript ftpcrack("foodnstuff"); diff --git a/doc/source/netscript/basicfunctions/getFavorToDonate.rst b/doc/source/netscript/basicfunctions/getFavorToDonate.rst index 8c9feb203..133788fbd 100644 --- a/doc/source/netscript/basicfunctions/getFavorToDonate.rst +++ b/doc/source/netscript/basicfunctions/getFavorToDonate.rst @@ -4,5 +4,10 @@ getFavorToDonate() Netscript Function .. js:function:: getFavorToDonate() :RAM cost: 0.1 GB + :returns: Amount of faction favor required to unlock donation. - Returns the amount of Faction favor required to be able to donate to a faction. + Example: + + .. code-block:: javascript + + getFavorToDonate() // returns: 150 \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/getGrowTime.rst b/doc/source/netscript/basicfunctions/getGrowTime.rst index 0c105c61b..443f76b01 100644 --- a/doc/source/netscript/basicfunctions/getGrowTime.rst +++ b/doc/source/netscript/basicfunctions/getGrowTime.rst @@ -1,16 +1,24 @@ getGrowTime() Netscript Function ================================ -.. js:function:: getGrowTime(hostname/ip[, hackLvl=current level]) +.. js:function:: getGrowTime(hostname[, hackLvl=current level]) - :param string hostname/ip: Hostname or IP of target server - :param number hackLvl: Optional hacking level for the calculation. Defaults to player's current hacking level :RAM cost: 0.05 GB - Returns the amount of time in seconds it takes to execute the *grow()* Netscript function on the target server. + :param string hostname: Hostname of target server. + :param number hackLvl: Optional hacking level for the calculation. Defaults + to player's current hacking level. + :returns: seconds it takes to execute :doc:`grow` on that server. - The function takes in an optional *hackLvl* parameter that can be specified - to see what the grow time would be at different hacking levels. + The function takes in an optional ``hackLvl`` parameter that can be + specified to see what the grow time would be at different hacking levels. - .. note:: For Hacknet Servers (the upgraded version of a Hacknet Node), this function will - return :code:`Infinity`. + + Example: + + .. code-block:: javascript + + getGrowTime("foodnstuff"); // returns: 53.4 + +.. note:: For Hacknet Servers (the upgraded version of a Hacknet Node), this function will + return ``Infinity``. diff --git a/doc/source/netscript/basicfunctions/getHackTime.rst b/doc/source/netscript/basicfunctions/getHackTime.rst index 768c26373..6c45c4e03 100644 --- a/doc/source/netscript/basicfunctions/getHackTime.rst +++ b/doc/source/netscript/basicfunctions/getHackTime.rst @@ -1,16 +1,22 @@ getHackTime() Netscript Function ================================ -.. js:function:: getHackTime(hostname/ip[, hackLvl=current level]) +.. js:function:: getHackTime(hostname[, hackLvl=current level]) - :param string hostname/ip: Hostname or IP of target server - :param number hackLvl: Optional hacking level for the calculation. Defaults to player's current hacking level :RAM cost: 0.05 GB + :param string hostname: Hostname of target server. + :param number hackLvl: Optional hacking level for the calculation. Defaults + to player's current hacking level. + :returns: seconds it takes to execute :doc:`hack` on that server. - Returns the amount of time in seconds it takes to execute the *hack()* Netscript function on the target server. + The function takes in an optional ``hackLvl`` parameter that can be + specified to see what the hack time would be at different hacking levels. - The function takes in an optional *hackLvl* parameter that can be specified - to see what the hack time would be at different hacking levels. + Example: + + .. code-block:: javascript + + getHackTime("foodnstuff"); // returns: 53.4 .. note:: For Hacknet Servers (the upgraded version of a Hacknet Node), this function will return :code:`Infinity`. diff --git a/doc/source/netscript/basicfunctions/getHackingLevel.rst b/doc/source/netscript/basicfunctions/getHackingLevel.rst index f87e324b6..ed085220e 100644 --- a/doc/source/netscript/basicfunctions/getHackingLevel.rst +++ b/doc/source/netscript/basicfunctions/getHackingLevel.rst @@ -4,5 +4,10 @@ getHackingLevel() Netscript Function .. js:function:: getHackingLevel() :RAM cost: 0.05 GB + :returns: The player's current hacking level. - Returns the player's current hacking level + Example: + + .. code-block:: javascript + + getHackingLevel(); // returns: 124 \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/getHackingMultipliers.rst b/doc/source/netscript/basicfunctions/getHackingMultipliers.rst index 37032122e..3c08c0cfc 100644 --- a/doc/source/netscript/basicfunctions/getHackingMultipliers.rst +++ b/doc/source/netscript/basicfunctions/getHackingMultipliers.rst @@ -4,9 +4,11 @@ getHackingMultipliers() Netscript Function .. js:function:: getHackingMultipliers() :RAM cost: 4 GB + :returns: object containing the player's hacking multipliers. These + multipliers are returned in decimal forms, not percentages (e.g. 1.5 + instead of 150%). - Returns an object containing the Player's hacking related multipliers. These multipliers are - returned in decimal forms, not percentages (e.g. 1.5 instead of 150%). The object has the following structure:: + Structure:: { chance: Player's hacking chance multiplier, @@ -15,7 +17,9 @@ getHackingMultipliers() Netscript Function growth: Player's hacking growth multiplier } - Example of how this can be used:: + Example: + + .. code-block:: javascript mults = getHackingMultipliers(); print(mults.chance); diff --git a/doc/source/netscript/basicfunctions/getHacknetMultipliers.rst b/doc/source/netscript/basicfunctions/getHacknetMultipliers.rst index d37eda610..b6a372075 100644 --- a/doc/source/netscript/basicfunctions/getHacknetMultipliers.rst +++ b/doc/source/netscript/basicfunctions/getHacknetMultipliers.rst @@ -4,9 +4,11 @@ getHacknetMultipliers() Netscript Function .. js:function:: getHacknetMultipliers() :RAM cost: 4 GB + :returns: object containing the player's hacknet multipliers. These + multipliers are returned in decimal forms, not percentages (e.g. 1.5 + instead of 150%). - Returns an object containing the Player's hacknet related multipliers. These multipliers are - returned in decimal forms, not percentages (e.g. 1.5 instead of 150%). The object has the following structure:: + Structure:: { production: Player's hacknet production multiplier, @@ -16,7 +18,9 @@ getHacknetMultipliers() Netscript Function levelCost: Player's hacknet level cost multiplier } - Example of how this can be used:: + Example: + + .. code-block:: javascript mults = getHacknetMultipliers(); print(mults.production); diff --git a/doc/source/netscript/basicfunctions/getHostname.rst b/doc/source/netscript/basicfunctions/getHostname.rst index 6e14224cd..76b78ac7c 100644 --- a/doc/source/netscript/basicfunctions/getHostname.rst +++ b/doc/source/netscript/basicfunctions/getHostname.rst @@ -4,5 +4,11 @@ getHostname() Netscript Function .. js:function:: getHostname() :RAM cost: 0.05 GB + :returns: Hostname of the server this script is running on. - Returns a string with the hostname of the server that the script is running on + Example: + + .. code-block:: javascript + + getHostname(); // returns: "foodnstuff" + diff --git a/doc/source/netscript/basicfunctions/getPortHandle.rst b/doc/source/netscript/basicfunctions/getPortHandle.rst index a0a6ed05c..e0f800efd 100644 --- a/doc/source/netscript/basicfunctions/getPortHandle.rst +++ b/doc/source/netscript/basicfunctions/getPortHandle.rst @@ -3,9 +3,9 @@ getPortHandle() Netscript Function .. js:function:: getPortHandle(port) - :param number port: Port number :RAM cost: 10 GB - Get a handle to a Netscript Port. See more details here: :ref:`netscript_ports` + :param number port: Port number + :returns: portHandle object. See :ref:`netscript_ports` **WARNING:** Port Handles only work in :ref:`netscriptjs`. They will not work in :ref:`netscript1`. diff --git a/doc/source/netscript/basicfunctions/getPurchasedServerCost.rst b/doc/source/netscript/basicfunctions/getPurchasedServerCost.rst index 764baa309..faf02ba06 100644 --- a/doc/source/netscript/basicfunctions/getPurchasedServerCost.rst +++ b/doc/source/netscript/basicfunctions/getPurchasedServerCost.rst @@ -6,11 +6,10 @@ getPurchasedServerCost() Netscript Function :RAM cost: 0.25 GB :param number ram: Amount of RAM of a potential purchased server. Must be a power of 2 (2, 4, 8, 16, etc.). Maximum value of 1048576 (2^20) + :returns: Cost to purchase a server with the specified amount of ``ram``. - Returns the cost to purchase a server with the specified amount of *ram*. + Example: - Examples:: + .. code-block:: javascript - for (i = 1; i <= 20; i++) { - tprint(i + " -- " + getPurchasedServerCost(Math.pow(2, i))); - } + getPurchasedServerCost(8192); // returns: 450560000 diff --git a/doc/source/netscript/basicfunctions/getPurchasedServerLimit.rst b/doc/source/netscript/basicfunctions/getPurchasedServerLimit.rst index 7784203dc..293187b18 100644 --- a/doc/source/netscript/basicfunctions/getPurchasedServerLimit.rst +++ b/doc/source/netscript/basicfunctions/getPurchasedServerLimit.rst @@ -4,5 +4,10 @@ getPurchasedServerLimit() Netscript Function .. js:function:: getPurchasedServerLimit() :RAM cost: 0.05 GB + :returns: The maximum number of servers you can purchase. - Returns the maximum number of servers you can purchase + Example: + + .. code-block:: javascript + + getPurchasedServerLimit() // returns: 25 \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/getPurchasedServerMaxRam.rst b/doc/source/netscript/basicfunctions/getPurchasedServerMaxRam.rst index 844e7ba18..1692f37a4 100644 --- a/doc/source/netscript/basicfunctions/getPurchasedServerMaxRam.rst +++ b/doc/source/netscript/basicfunctions/getPurchasedServerMaxRam.rst @@ -4,5 +4,10 @@ getPurchasedServerMaxRam() Netscript Function .. js:function:: getPurchasedServerMaxRam() :RAM cost: 0.05 GB + :returns: The maximum RAM that a purchased server can have. - Returns the maximum RAM that a purchased server can have + Example: + + .. code-block:: javascript + + getPurchasedServerMaxRam(); // returns: 1048576 \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/getPurchasedServers.rst b/doc/source/netscript/basicfunctions/getPurchasedServers.rst index 89b3cfedc..c7f360008 100644 --- a/doc/source/netscript/basicfunctions/getPurchasedServers.rst +++ b/doc/source/netscript/basicfunctions/getPurchasedServers.rst @@ -1,11 +1,13 @@ getPurchasedServers() Netscript Function ======================================== -.. js:function:: getPurchasedServers([hostname=true]) +.. js:function:: getPurchasedServers() - :param boolean hostname: - Specifies whether hostnames or IP addresses should be returned. If it's true then hostnames will be returned, and if false - then IPs will be returned. If this argument is omitted then it is true by default :RAM cost: 2.25 GB + :returns: String array of hostnames of all of the servers you have purchased. - Returns an array with either the hostnames or IPs of all of the servers you have purchased. + Example: + + .. code-block:: javascript + + getPurchasedServers(); // returns: ['grow-server-0', 'grow-server-1', 'weaken-server-0'] diff --git a/doc/source/netscript/basicfunctions/getScriptExpGain.rst b/doc/source/netscript/basicfunctions/getScriptExpGain.rst index 65f6f9c86..2bdc50a38 100644 --- a/doc/source/netscript/basicfunctions/getScriptExpGain.rst +++ b/doc/source/netscript/basicfunctions/getScriptExpGain.rst @@ -1,14 +1,18 @@ getScriptExpGain() Netscript Function ===================================== -.. js:function:: getScriptExpGain([scriptname], [hostname/ip], [args...]) +.. js:function:: getScriptExpGain([scriptname[, hostname[, args...]]]) - :param string scriptname: Filename of script - :param string hostname/ip: Server on which script is running - :param args...: Arguments that the script is running with :RAM cost: 0.1 GB + :param string scriptname: Filename of script. + :param string hostname: Server on which script is running. + :param args...: Arguments that the script is running with. + :returns: The amount of hacking experience the specified script generates + while online. - Returns the amount of hacking experience the specified script generates while online (when the game is open, does not apply for offline experience gains). - Remember that a script is uniquely identified by both its name and its arguments. + This function can also return the total experience gain rate of all of your + active scripts by running the function with no arguments. + + .. note:: A script is uniquely identified by both its name and its + arguments. - This function can also return the total experience gain rate of all of your active scripts by running the function with no arguments. diff --git a/doc/source/netscript/basicfunctions/getScriptIncome.rst b/doc/source/netscript/basicfunctions/getScriptIncome.rst index e3496c015..8dd1a4f3f 100644 --- a/doc/source/netscript/basicfunctions/getScriptIncome.rst +++ b/doc/source/netscript/basicfunctions/getScriptIncome.rst @@ -1,18 +1,19 @@ getScriptIncome() Netscript Function ==================================== -.. js:function:: getScriptIncome([scriptname], [hostname/ip], [args...]) +.. js:function:: getScriptIncome([scriptname[, hostname/ip[, [args...]]]) + :RAM cost: 0.1 GB :param string scriptname: Filename of script :param string hostname/ip: Server on which script is running :param args...: Arguments that the script is running with - :RAM cost: 0.1 GB + :returns: Amount of income the specified script generates while online. - Returns the amount of income the specified script generates while online (when the game is open, does not apply for offline income). - Remember that a script is uniquely identified by both its name and its arguments. So for example if you ran a script with the arguments - "foodnstuff" and "5" then in order to use this function to get that script's income you must specify those same arguments in the same order - in this function call. + If called with no arguments this function will return an array of two + values. The first value is the total income ($ / second) of all of your + active scripts (scripts that are currently running on any server). The + second value is the total income ($ / second) that you've earned from + scripts since you last installed Augmentations. - This function can also be called with no arguments. If called with no arguments, then this function will return an array of two values. The - first value is the total income ($ / second) of all of your active scripts (scripts that are currently running on any server). The second value - is the total income ($ / second) that you've earned from scripts since you last installed Augmentations. + .. note:: A script is uniquely identified by both its name and its + arguments. \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/getScriptLogs.rst b/doc/source/netscript/basicfunctions/getScriptLogs.rst index ac721c4d3..c4b15800a 100644 --- a/doc/source/netscript/basicfunctions/getScriptLogs.rst +++ b/doc/source/netscript/basicfunctions/getScriptLogs.rst @@ -1,27 +1,27 @@ getScriptLogs() Netscript Function ================================== -.. js:function:: getScriptLogs([fn], [hostname/ip=current ip], [args...]) +.. js:function:: getScriptLogs([filename[, hostname=current hostname[, args...]]]) - :param string fn: Optional. Filename of script to get logs from. - :param string ip: Optional. IP or hostname of the server that the script is on - :param args...: Arguments to identify which scripts to get logs for :RAM cost: 0 GB + :param string filename: Optional. Filename of script to get logs from. + :param string hostname: Optional. Hostname of the server running the script. + :param args...: Arguments to identify which scripts to get logs for + :returns: Array of string, each line being a logged line. Chronological. - Returns a script's logs. The logs are returned as an array, where each - line is an element in the array. The most recently logged line is at the - end of the array. - - Note that there is a maximum number of lines that a script stores in its logs. +.. note:: There is a maximum number of lines that a script stores in its logs. This is configurable in the game's options. - If the function is called with no arguments, it will return the current script's logs. + If the function is called with no arguments, it will return the current + script's logs. - Otherwise, the `fn`, `hostname/ip,` and `args...` arguments can be used to get the logs - from another script. Remember that scripts are uniquely identified by both - their names and arguments. + Otherwise, the ``filename``, ``hostname``, and ``args...`` arguments can be + used to get the logs from another script. Remember that scripts are uniquely + identified by both their names and arguments. - Examples:: + Example: + + .. code-block:: javascript // Get logs from foo.script on the current server that was run with no args getScriptLogs("foo.script"); diff --git a/doc/source/netscript/basicfunctions/getScriptName.rst b/doc/source/netscript/basicfunctions/getScriptName.rst index cc7de660b..436041846 100644 --- a/doc/source/netscript/basicfunctions/getScriptName.rst +++ b/doc/source/netscript/basicfunctions/getScriptName.rst @@ -4,5 +4,10 @@ getScriptName() Netscript Function .. js:function:: getScriptName() :RAM cost: 0 GB + :returns: Current script name. - Returns the current script name + Example: + + .. code-block:: javascript + + getScriptName(); // returns: "example.script" diff --git a/doc/source/netscript/basicfunctions/getScriptRam.rst b/doc/source/netscript/basicfunctions/getScriptRam.rst index 2123d8ed0..9010baa25 100644 --- a/doc/source/netscript/basicfunctions/getScriptRam.rst +++ b/doc/source/netscript/basicfunctions/getScriptRam.rst @@ -1,11 +1,16 @@ getScriptRam() Netscript Function ================================= -.. js:function:: getScriptRam(scriptname[, hostname/ip]) +.. js:function:: getScriptRam(filename[, hostname]) - :param string scriptname: Filename of script. This is case-sensitive. - :param string hostname/ip: Hostname or IP of target server the script is located on. This is optional, If it is not specified then the function will set the current server as the target server. :RAM cost: 0.1 GB + :param string filename: Filename of script. + :param string hostname: Hostname of target server the script is located on. + Default to the server this script is running on. + :returns: Amount of RAM required to run the script, 0 if it does not exist. - Returns the amount of RAM required to run the specified script on the target server. Returns - 0 if the script does not exist. + Example: + + .. code-block:: javascript + + getScriptRam("grow.script"); // returns: 1.75 diff --git a/doc/source/netscript/basicfunctions/getServerBaseSecurityLevel.rst b/doc/source/netscript/basicfunctions/getServerBaseSecurityLevel.rst index 162ee4c38..59ac978a5 100644 --- a/doc/source/netscript/basicfunctions/getServerBaseSecurityLevel.rst +++ b/doc/source/netscript/basicfunctions/getServerBaseSecurityLevel.rst @@ -1,12 +1,28 @@ getServerBaseSecurityLevel() Netscript Function =============================================== -.. js:function:: getServerBaseSecurityLevel(hostname/ip) +.. js:function:: getServerBaseSecurityLevel(hostname) - :param string hostname/ip: Hostname or IP of target server :RAM cost: 0.1 GB + :param string hostname: Hostname of target server. + :returns: Base security level of target server. - Returns the base security level of the target server. This is the security level that the server starts out with. - This is different than *getServerSecurityLevel()* because *getServerSecurityLevel()* returns the current - security level of a server, which can constantly change due to *hack()*, *grow()*, and *weaken()*, calls on that - server. The base security level will stay the same until you reset by installing an Augmentation(s). + The base security level is the security level that the server starts out with. + + This function isn't particularly useful. + :doc:`getServerSecurityLevel` and + :doc:`getServerMinSecurityLevel` are more often + used. + + Example: + + .. code-block:: javascript + + getServerBaseSecurityLevel('foodnstuff'); // returns: 9 + +.. note:: This is different than :doc:`getServerSecurityLevel` + because :doc:`getServerSecurityLevel` returns the current + security level of a server, which can constantly change due to + :doc:`hack`, :doc:`grow`, and :doc:`weaken` calls on + that server. The base security level will stay the same until you reset + by installing augmentation(s). diff --git a/doc/source/netscript/basicfunctions/getServerGrowth.rst b/doc/source/netscript/basicfunctions/getServerGrowth.rst index 8fbdd3d45..e7a721fd4 100644 --- a/doc/source/netscript/basicfunctions/getServerGrowth.rst +++ b/doc/source/netscript/basicfunctions/getServerGrowth.rst @@ -1,12 +1,19 @@ getServerGrowth() Netscript Function ==================================== -.. js:function:: getServerGrowth(hostname/ip) +.. js:function:: getServerGrowth(hostname) - :param string hostname/ip: Hostname or IP of target server :RAM cost: 0.1 GB + :param string hostname: Hostname of target server. + :returns: Server growth parameter. - Returns the server's instrinsic "growth parameter". This growth parameter is a number - between 1 and 100 that represents how quickly the server's money grows. This parameter affects the - percentage by which the server's money is increased when using the *grow()* function. A higher - growth parameter will result in a higher percentage increase from *grow()*. + The growth parameter is a number between 1 and 100 affects the percentage by + which the server's money is increased when using the :doc:`grow` + function. A higher growth parameter will result in a higher percentage + increase. + + Example: + + .. code-block:: javascript + + getServerGrowth('foodnstuff'); // returns: 5 diff --git a/doc/source/netscript/basicfunctions/getServerMaxMoney.rst b/doc/source/netscript/basicfunctions/getServerMaxMoney.rst index c9feeb8be..d9cc9017b 100644 --- a/doc/source/netscript/basicfunctions/getServerMaxMoney.rst +++ b/doc/source/netscript/basicfunctions/getServerMaxMoney.rst @@ -1,9 +1,14 @@ getServerMaxMoney() Netscript Function ====================================== -.. js:function:: getServerMaxMoney(hostname/ip) +.. js:function:: getServerMaxMoney(hostname) - :param string hostname/ip: Hostname or IP of target server :RAM cost: 0.1 GB + :param string hostname: Hostname of target server. + :returns: Maximum amount of money that can be available on a server. - Returns the maximum amount of money that can be available on a server + Example: + + .. code-block:: javascript + + getServerMaxMoney('foodnstuff'); // returns: 4000000 diff --git a/doc/source/netscript/basicfunctions/getServerMinSecurityLevel.rst b/doc/source/netscript/basicfunctions/getServerMinSecurityLevel.rst index 7036c0f7e..4f34fdad5 100644 --- a/doc/source/netscript/basicfunctions/getServerMinSecurityLevel.rst +++ b/doc/source/netscript/basicfunctions/getServerMinSecurityLevel.rst @@ -1,9 +1,14 @@ getServerMinSecurityLevel() Netscript Function ============================================== -.. js:function:: getServerMinSecurityLevel(hostname/ip) +.. js:function:: getServerMinSecurityLevel(hostname) - :param string hostname/ip: Hostname or IP of target server :RAM cost: 0.1 GB + :param string hostname: Hostname of target server. + :returns: The minimum security level of the target server. - Returns the minimum security level of the target server + Example: + + .. code-block:: javascript + + getServerMinSecurityLevel('foodnstuff'); // returns: 3 diff --git a/doc/source/netscript/basicfunctions/getServerMoneyAvailable.rst b/doc/source/netscript/basicfunctions/getServerMoneyAvailable.rst index 55b909396..cdb30b98e 100644 --- a/doc/source/netscript/basicfunctions/getServerMoneyAvailable.rst +++ b/doc/source/netscript/basicfunctions/getServerMoneyAvailable.rst @@ -1,15 +1,19 @@ getServerMoneyAvailable() Netscript Function ============================================ -.. js:function:: getServerMoneyAvailable(hostname/ip) +.. js:function:: getServerMoneyAvailable(hostname) - :param string hostname/ip: Hostname or IP of target server :RAM cost: 0.1 GB + :param string hostname: Hostname of target server. + :returns: Money available on that server. - Returns the amount of money available on a server. **Running this function on the home computer will return - the player's money.** + .. note:: - Example:: + Running this function on the home computer will return the player's money. - getServerMoneyAvailable("foodnstuff"); - getServerMoneyAvailable("home"); //Returns player's money + Example: + + .. code-block:: javascript + + getServerMoneyAvailable("foodnstuff"); // returns: 120000 + getServerMoneyAvailable("home"); // returns: 1000 \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/getServerNumPortsRequired.rst b/doc/source/netscript/basicfunctions/getServerNumPortsRequired.rst index 1f05a6141..2693695cc 100644 --- a/doc/source/netscript/basicfunctions/getServerNumPortsRequired.rst +++ b/doc/source/netscript/basicfunctions/getServerNumPortsRequired.rst @@ -1,9 +1,15 @@ getServerNumPortsRequired() Netscript Function ============================================== -.. js:function:: getServerNumPortsRequired(hostname/ip) +.. js:function:: getServerNumPortsRequired(hostname) - :param string hostname/ip: Hostname or IP of target server :RAM cost: 0.1 GB + :param string hostname: Hostname of target server. + :returns: The number of open ports required to successfully run NUKE.exe on + the specified server. - Returns the number of open ports required to successfully run NUKE.exe on the specified server. + Example: + + .. code-block:: javascript + + getServerNumPortsRequired("unitalife"); // returns: 4 diff --git a/doc/source/netscript/basicfunctions/getServerRam.rst b/doc/source/netscript/basicfunctions/getServerRam.rst index a8a8cb200..40e46df42 100644 --- a/doc/source/netscript/basicfunctions/getServerRam.rst +++ b/doc/source/netscript/basicfunctions/getServerRam.rst @@ -1,17 +1,21 @@ getServerRam() Netscript Function ================================= -.. js:function:: getServerRam(hostname/ip) +.. js:function:: getServerRam(hostname) - :param string hostname/ip: Hostname or IP of target server :RAM cost: 0.1 GB + :param string hostname: Hostname of target server. + :returns: An array of 2 number, first number is the total RAM, second the + used RAM. Returns an array with two elements that gives information about a server's memory (RAM). The first element in the array is the amount of RAM that the server has total (in GB). The second element in the array is the amount of RAM that is currently being used on the server (in GB). - Example:: + Example: - res = getServerRam("helios"); + .. code-block:: javascript + + res = getServerRam("helios"); // returns: [5, 10] totalRam = res[0]; ramUsed = res[1]; diff --git a/doc/source/netscript/basicfunctions/getServerRequiredHackingLevel.rst b/doc/source/netscript/basicfunctions/getServerRequiredHackingLevel.rst index 122c5b41e..f006a1205 100644 --- a/doc/source/netscript/basicfunctions/getServerRequiredHackingLevel.rst +++ b/doc/source/netscript/basicfunctions/getServerRequiredHackingLevel.rst @@ -1,9 +1,14 @@ getServerRequiredHackingLevel() Netscript Function ================================================== -.. js:function:: getServerRequiredHackingLevel(hostname/ip) +.. js:function:: getServerRequiredHackingLevel(hostname) - :param string hostname/ip: Hostname or IP of target server :RAM cost: 0.1 GB + :param string hostname: Hostname of target server. + :returns: The required hacking level of target server. - Returns the required hacking level of the target server + Example: + + .. code-block:: javascript + + getServerRequiredHackingLevel("foodnstuff"); // returns: 5 \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/getServerSecurityLevel.rst b/doc/source/netscript/basicfunctions/getServerSecurityLevel.rst index a2c612170..b6dd116a4 100644 --- a/doc/source/netscript/basicfunctions/getServerSecurityLevel.rst +++ b/doc/source/netscript/basicfunctions/getServerSecurityLevel.rst @@ -1,10 +1,14 @@ getServerSecurityLevel() Netscript Function =========================================== -.. js:function:: getServerSecurityLevel(hostname/ip) +.. js:function:: getServerSecurityLevel(hostname) - :param string hostname/ip: Hostname or IP of target server :RAM cost: 0.1 GB + :param string hostname: Hostname of target server. + :returns: The security level of the target server. - Returns the security level of the target server. A server's security level is denoted by a number, typically - between 1 and 100 (but it can go above 100). + Example: + + .. code-block:: javascript + + getServerSecurityLevel("foodnstuff"); // returns: 3.45 \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/getTimeSinceLastAug.rst b/doc/source/netscript/basicfunctions/getTimeSinceLastAug.rst index b81d48482..877eeb7b8 100644 --- a/doc/source/netscript/basicfunctions/getTimeSinceLastAug.rst +++ b/doc/source/netscript/basicfunctions/getTimeSinceLastAug.rst @@ -4,5 +4,10 @@ getTimeSinceLastAug() Netscript Function .. js:function:: getTimeSinceLastAug() :RAM cost: 0.05 GB + :returns: Milliseconds since you last installed augmentations. - Returns the amount of time in milliseconds that have passed since you last installed Augmentations + Example: + + .. code-block:: javascript + + getTimeSinceLastAug(); // returns: 13912400 \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/getWeakenTime.rst b/doc/source/netscript/basicfunctions/getWeakenTime.rst index 056aaea27..103895cbb 100644 --- a/doc/source/netscript/basicfunctions/getWeakenTime.rst +++ b/doc/source/netscript/basicfunctions/getWeakenTime.rst @@ -1,16 +1,23 @@ getWeakenTime() Netscript Function ================================== -.. js:function:: getWeakenTime(hostname/ip[, hackLvl=current level]) +.. js:function:: getWeakenTime(hostname[, hackLvl=current level]) - :param string hostname/ip: Hostname or IP of target server - :param number hackLvl: Optional hacking level for the calculation. Defaults to player's current hacking level :RAM cost: 0.05 GB - - Returns the amount of time in seconds it takes to execute the *weaken()* Netscript function on the target server. + :param string hostname: Hostname of target server. + :param number hackLvl: Optional hacking level for the calculation. Defaults + to player's current hacking level. + :returns: seconds it takes to execute the :doc:`weaken` Netscript + function on the target server. The function takes in an optional *hackLvl* parameter that can be specified to see what the weaken time would be at different hacking levels. + Example: + + .. code-block:: javascript + + getWeakenTime("foodnstuff"); // returns: 34.5 + .. note:: For Hacknet Servers (the upgraded version of a Hacknet Node), this function will return :code:`Infinity`. diff --git a/doc/source/netscript/basicfunctions/grow.rst b/doc/source/netscript/basicfunctions/grow.rst index fc5257f11..ae9e43ad2 100644 --- a/doc/source/netscript/basicfunctions/grow.rst +++ b/doc/source/netscript/basicfunctions/grow.rst @@ -1,9 +1,10 @@ grow() Netscript Function ========================= -.. js:function:: grow(hostname/ip[, opts={}]) +.. js:function:: grow(hostname[, opts={}]) - :param string hostname/ip: IP or hostname of the target server to grow + :RAM cost: 0.15 GB + :param string hostname: Hostname of the target server. :param object opts: Optional parameters for configuring function behavior. Properties: * threads (*number*) - Number of threads to use for this function. @@ -12,18 +13,25 @@ grow() Netscript Function :ref:`gameplay_stock_market_player_actions_influencing_stock` :returns: The number by which the money on the server was multiplied for the growth - :RAM cost: 0.15 GB - Use your hacking skills to increase the amount of money available on a server. The runtime for this command depends on your hacking - level and the target server's security level. When grow() completes, the money available on a target server will be increased by a - certain, fixed percentage. This percentage is determined by the target server's growth rate (which varies between servers) and security level. - Generally, higher-level servers have higher growth rates. The getServerGrowth() function can be used to obtain a server's growth rate. + Increase the amount of money available on a server. The time it takes to + execute depends on your hacking level and the target server's security + level. When :doc:`grow` completes, the money available on a target + server will be increased by a certain, fixed percentage. This percentage is + determined by the target server's growth rate (which varies between servers) + and security level. Generally, higher-level servers have higher growth + rates. The :doc:`getServerGrowth` function can be used to + obtain a server's growth rate. - Like hack(), grow() can be called on any server, regardless of where the script is running. The grow() command requires - root access to the target server, but there is no required hacking level to run the command. It also raises the security level - of the target server by 0.004. + Like :doc:`hack`, :doc:`grow` can be called on any server, from + any server. The :doc:`grow` command requires root access to the target + server, but there is no required hacking level to run the command. It also + raises the security level of the target server by 0.004 per thread. - Example:: + Example: - grow("foodnstuff"); - grow("foodnstuff", { threads: 5 }); // Only use 5 threads to grow + .. code-block:: javascript + + while(true) { + grow("foodnstuff"); + } diff --git a/doc/source/netscript/basicfunctions/growthAnalyze.rst b/doc/source/netscript/basicfunctions/growthAnalyze.rst index 76120ae15..2d60915d2 100644 --- a/doc/source/netscript/basicfunctions/growthAnalyze.rst +++ b/doc/source/netscript/basicfunctions/growthAnalyze.rst @@ -1,24 +1,23 @@ growthAnalyze() Netscript Function ================================== -.. js:function:: growthAnalyze(hostname/ip, growthAmount) +.. js:function:: growthAnalyze(hostname, growthAmount) - :param string hostname/ip: IP or hostname of server to analyze - :param number growthAmount: Multiplicative factor by which the server is grown. Decimal form. Must be >= 1. - :returns: The amount of grow() calls needed to grow the specified server by the specified amount :RAM cost: 1 GB + :param string hostname: Hostname of server to analyze. + :param number growthAmount: Multiplicative factor by which the server is + grown. Decimal form. Must be >= 1. + :returns: The amount of :doc:`grow` threads needed to grow the specified + server by the specified amount. - This function returns the number of "growths" needed in order to increase the amount - of money available on the specified server by the specified amount. + Example: - The specified amount is multiplicative and is in decimal form, not percentage. + .. code-block:: javascript - For example, if you want to determine how many `grow()` calls you need - to double the amount of money on `foodnstuff`, you would use:: + // How many grow threads are needed to double the current money on 'foodnstuff' + growthAnalyze("foodnstuff", 2); // returns: 5124 - growthAnalyze("foodnstuff", 2); - - If this returns 100, then this means you need to call `grow()` 100 times - in order to double the money (or once with 100 threads). + If this returns 5124, then this means you need to call :doc:`grow` + 5124 times in order to double the money (or once with 5124 threads). **Warning**: The value returned by this function isn't necessarily a whole number. diff --git a/doc/source/netscript/basicfunctions/hack.rst b/doc/source/netscript/basicfunctions/hack.rst index e7f7718ea..abac13856 100644 --- a/doc/source/netscript/basicfunctions/hack.rst +++ b/doc/source/netscript/basicfunctions/hack.rst @@ -1,29 +1,35 @@ hack() Netscript Function ========================= -.. js:function:: hack(hostname/ip[, opts={}]) +.. js:function:: hack(hostname[, opts={}]) - :param string hostname/ip: IP or hostname of the target server to hack + :RAM cost: 0.1 GB + :param string hostname: Hostname of the target server. :param object opts: Optional parameters for configuring function behavior. Properties: * threads (*number*) - Number of threads to use for this function. Must be less than or equal to the number of threads the script is running with. * stock (*boolean*) - If true, the function can affect the stock market. See :ref:`gameplay_stock_market_player_actions_influencing_stock` - :returns: The amount of money stolen if the hack is successful, and zero otherwise - :RAM cost: 0.1 GB - Function that is used to try and hack servers to steal money and gain hacking experience. The runtime for this command depends - on your hacking level and the target server's security level. In order to hack a server you must first gain root access - to that server and also have the required hacking level. + Function that is used to try and hack servers to steal money and gain + hacking experience. The runtime for this command depends on your hacking + level and the target server's security level. In order to hack a server you + must first gain root access to that server and also have the required + hacking level. - A script can hack a server from anywhere. It does not need to be running on the same server to hack that server. For example, - you can create a script that hacks the 'foodnstuff' server and run that script on any server in the game. + A script can hack a server from anywhere. It does not need to be running on + the same server to hack that server. For example, you can create a script + that hacks the 'foodnstuff' server and run that script on any server in the + game. - A successful hack() on a server will raise that server's security level by 0.002. + A successful :doc:`hack` on a server will raise that server's security + level by 0.002. - Example:: + Example: + + .. code-block:: javascript hack("foodnstuff"); hack("10.1.2.3"); diff --git a/doc/source/netscript/basicfunctions/hackAnalyzePercent.rst b/doc/source/netscript/basicfunctions/hackAnalyzePercent.rst index b0a64236c..c83e0c07b 100644 --- a/doc/source/netscript/basicfunctions/hackAnalyzePercent.rst +++ b/doc/source/netscript/basicfunctions/hackAnalyzePercent.rst @@ -1,20 +1,22 @@ hackAnalyzePercent() Netscript Function ======================================= -.. js:function:: hackAnalyzePercent(hostname/ip) +.. js:function:: hackAnalyzePercent(hostname) - :param string hostname/ip: IP or hostname of target server - :returns: The percentage of money you will steal from the target server with a single hack :RAM cost: 1 GB + :param string hostname: Hostname of target server. + :returns: The percentage of money you will steal from the target server with + a single hack. Returns the percentage of the specified server's money you will steal with a - single hack. This value is returned in **percentage form, not decimal (Netscript - functions typically return in decimal form, but not this one).** + single hack. This value is returned in percentage form, not decimal. - For example, assume the following returns 1:: + For example, assume the following returns 1: - hackAnalyzePercent("foodnstuff"); + .. code-block:: javascript - This means that if hack the `foodnstuff` server, then you will steal 1% of its - total money. If you `hack()` using N threads, then you will steal N% of its total + hackAnalyzePercent("foodnstuff"); // returns: 1 + + This means that if hack the 'foodnstuff' server, then you will steal 1% of its + total money. If you :doc:`hack` using N threads, then you will steal N% of its total money. diff --git a/doc/source/netscript/basicfunctions/hackAnalyzeThreads.rst b/doc/source/netscript/basicfunctions/hackAnalyzeThreads.rst index 445b70c4c..05df6387e 100644 --- a/doc/source/netscript/basicfunctions/hackAnalyzeThreads.rst +++ b/doc/source/netscript/basicfunctions/hackAnalyzeThreads.rst @@ -1,24 +1,28 @@ hackAnalyzeThreads() Netscript Function ======================================= -.. js:function:: hackAnalyzeThreads(hostname/ip, hackAmount) +.. js:function:: hackAnalyzeThreads(hostname, hackAmount) - :param string hostname/ip: IP or hostname of server to analyze - :param number hackAmount: Amount of money you want to hack from the server - :returns: The number of threads needed to hack() the server for *hackAmount* money :RAM cost: 1 GB + :param string hostname: Hostname of server to analyze. + :param number hackAmount: Amount of money you want to hack from the server. + :returns: The number of threads needed to :doc:`hack` the server for + ``hackAmount`` money. This function returns the number of script threads you need when running - the `hack()` command to steal the specified amount of money from the target server. + the :doc:`hack` command to steal the specified amount of money from + the target server. - If `hackAmount` is less than zero or greater than the amount of money available - on the server, then this function returns -1. + If ``hackAmount`` is less than zero or greater than the amount of money + available on the server, then this function returns -1. - For example, let's say the `foodnstuff` server has $10m and you run:: + For example, let's say the 'foodnstuff' server has $10m and you run: + + .. code-block:: javascript hackAnalyzeThreads("foodnstuff", 1e6); - If this function returns 50, this means that if your next `hack()` call + If this function returns 50, this means that if your next :doc:`hack` call is run on a script with 50 threads, it will steal $1m from the `foodnstuff` server. .. warning:: The value returned by this function isn't necessarily a whole number. diff --git a/doc/source/netscript/basicfunctions/hackChance.rst b/doc/source/netscript/basicfunctions/hackChance.rst index 714b8ef44..a5792da97 100644 --- a/doc/source/netscript/basicfunctions/hackChance.rst +++ b/doc/source/netscript/basicfunctions/hackChance.rst @@ -1,11 +1,16 @@ hackChance() Netscript Function =============================== -.. js:function:: hackChance(hostname/ip) +.. js:function:: hackChance(hostname) - :param string hostname/ip: IP or hostname of target server - :returns: The chance you have of successfully hacking the target server :RAM cost: 1 GB + :param string hostname: Hostname of target server. + :returns: The chance you have of successfully hacking the target server. + in decimal form. - Returns the chance you have of successfully hacking the specified server. This - returned value is in decimal form, not percentage. + Example: + + .. code-block:: javascript + + hackChance("foodnstuff"); // returns: .5 + // So 50% chance to hack "foodnstuff" \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/hasRootAccess.rst b/doc/source/netscript/basicfunctions/hasRootAccess.rst index ee561eb7b..da35cef8a 100644 --- a/doc/source/netscript/basicfunctions/hasRootAccess.rst +++ b/doc/source/netscript/basicfunctions/hasRootAccess.rst @@ -1,14 +1,15 @@ hasRootAccess() Netscript Function ================================== -.. js:function:: hasRootAccess(hostname/ip) +.. js:function:: hasRootAccess(hostname) - :param string hostname/ip: Hostname or IP of the target server :RAM cost: 0.05 GB + :param string hostname: Hostname of the target server. + :returns: ``true`` if you have root access on the target server. - Returns a boolean indicating whether or not the player has root access to the specified target server. + Example: - Example:: + .. code-block:: javascript if (hasRootAccess("foodnstuff") == false) { nuke("foodnstuff"); diff --git a/doc/source/netscript/basicfunctions/httpworm.rst b/doc/source/netscript/basicfunctions/httpworm.rst index 56a90ebe6..41a3c9348 100644 --- a/doc/source/netscript/basicfunctions/httpworm.rst +++ b/doc/source/netscript/basicfunctions/httpworm.rst @@ -1,13 +1,16 @@ httpworm() Netscript Function ============================= -.. js:function:: httpworm(hostname/ip) +.. js:function:: httpworm(hostname) - :param string hostname/ip: IP or hostname of the target server :RAM cost: 0.05 GB + :param string hostname: Hostname of the target server. - Runs the HTTPWorm.exe program on the target server. HTTPWorm.exe must exist on your home computer. + Runs the HTTPWorm.exe program on the target server. HTTPWorm.exe must exist + on your home computer. - Example:: + Example: + + .. code-block:: javascript httpworm("foodnstuff"); diff --git a/doc/source/netscript/basicfunctions/isLogEnabled.rst b/doc/source/netscript/basicfunctions/isLogEnabled.rst index 8967b4cf7..bcef52e91 100644 --- a/doc/source/netscript/basicfunctions/isLogEnabled.rst +++ b/doc/source/netscript/basicfunctions/isLogEnabled.rst @@ -1,10 +1,14 @@ isLogEnabled() Netscript Function ================================= -.. js:function:: isLogEnabled(fn) +.. js:function:: isLogEnabled(functionName) - :param string fn: Name of function to check :RAM cost: 0 GB + :param string functionName: Name of function to check. + :returns: ``true`` is logs are enabled for this function or for 'ALL' - Returns a boolean indicating whether or not logging is enabled for that - function (or 'ALL') + Example: + + .. code-block:: javascript + + isLogEnabled('hack'); // returns: true \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/isRunning.rst b/doc/source/netscript/basicfunctions/isRunning.rst index 41afdd46a..3b74286df 100644 --- a/doc/source/netscript/basicfunctions/isRunning.rst +++ b/doc/source/netscript/basicfunctions/isRunning.rst @@ -1,29 +1,40 @@ isRunning() Netscript Function ============================== -.. js:function:: isRunning(filename, hostname/ip, [args...]) +.. js:function:: isRunning(filename, hostname, [args...]) - :param string filename: Filename of script to check. This is case-sensitive. - :param string hostname/ip: Hostname or IP of target server - :param args...: Arguments to specify/identify which scripts to search for :RAM cost: 0.1 GB + :param string filename: Filename of script to check. case-sensitive. + :param string hostname: Hostname of target server. + :param args...: Arguments to specify/identify which scripts to search for + :returns: ``true`` if that script with those args is running on that server. - Returns a boolean indicating whether the specified script is running on the target server. Remember that a script is - uniquely identified by both its name and its arguments. + .. note:: + + Remember that a script is uniquely identified by both its name and its arguments. **Examples:** - In this first example below, the function call will return true if there is a script named *foo.script* with no arguments - running on the *foodnstuff* server, and false otherwise:: + In this first example below, the function call will return true if there is + a script named ``foo.script`` with no arguments running on the + ``foodnstuff`` server, and false otherwise: - isRunning("foo.script", "foodnstuff"); + .. code-block:: javascript - In this second example below, the function call will return true if there is a script named *foo.script* with no arguments - running on the current server, and false otherwise:: + isRunning("foo.script", "foodnstuff"); - isRunning("foo.script", getHostname()); + In this second example below, the function call will return true if there is + a script named ``foo.script`` with no arguments running on the current + server, and false otherwise: - In this next example below, the function call will return true if there is a script named *foo.script* running with the arguments - 1, 5, and "test" (in that order) on the *joesguns* server, and false otherwise:: + .. code-block:: javascript - isRunning("foo.script", "joesguns", 1, 5, "test"); + isRunning("foo.script", getHostname()); + + In this next example below, the function call will return true if there is a + script named ``foo.script`` running with the arguments 1, 5, and "test" (in + that order) on the ``joesguns`` server, and false otherwise: + + .. code-block:: javascript + + isRunning("foo.script", "joesguns", 1, 5, "test"); diff --git a/doc/source/netscript/basicfunctions/kill.rst b/doc/source/netscript/basicfunctions/kill.rst index 7d695628a..b7de6411c 100644 --- a/doc/source/netscript/basicfunctions/kill.rst +++ b/doc/source/netscript/basicfunctions/kill.rst @@ -1,47 +1,57 @@ kill() Netscript Function ========================= -.. js:function:: kill(script, hostname/ip, [args...]) +.. js:function:: kill(script, hostname, [args...]) - :param string script: Filename of the script to kill - :param string hostname/ip: IP or hostname of the server on which to kill the script - :param args...: Arguments to identify which script to kill :RAM cost: 0.5 GB + :param string script: Filename of the script to kill. + :param string hostname: Hostname of the server on which to kill the script. + :param args...: Arguments to identify which script to kill. + :returns: ``true`` is that script was killed. - Kills the script on the target server specified by the script's name and arguments. Remember that scripts - are uniquely identified by both their name and arguments. For example, if *foo.script* is run with the argument 1, then this - is not the same as *foo.script* run with the argument 2, even though they have the same code. - - If this function successfully kills the specified script, then it will return true. Otherwise, it will return false. + Kills the script on the target server specified by the script's name and + arguments. Remember that scripts are uniquely identified by both their name + and arguments. For example, if ``foo.script`` is run with the argument 1, + then this is not the same as ``foo.script`` run with the argument 2, even + though they have the same code. Examples: - The following example will try to kill a script named *foo.script* on the *foodnstuff* server that was ran with no arguments:: + The following example will try to kill a script named ``foo.script`` on the + ``foodnstuff`` server that was ran with no arguments: + + .. code-block:: javascript kill("foo.script", "foodnstuff"); - The following will try to kill a script named *foo.script* on the current server that was ran with no arguments:: + The following will try to kill a script named ``foo.script`` on the current + server that was ran with no arguments: + + .. code-block:: javascript kill("foo.script", getHostname()); - The following will try to kill a script named *foo.script* on the current server that was ran with the arguments 1 and "foodnstuff":: + The following will try to kill a script named ``foo.script`` on the current + server that was ran with the arguments 1 and "foodnstuff": + + .. code-block:: javascript kill("foo.script", getHostname(), 1, "foodnstuff"); .. js:function:: kill(scriptPid) - :param number scriptPid: PID of the script to kill :RAM cost: 0.5 GB + :param number scriptPid: PID of the script to kill + :returns: ``true`` that script was killed. - Kills the script with the specified PID. Killing a script by its PID will typically - have better performance, especially if you have many scripts running. + Kills the script with the specified PID. Killing a script by its PID will + typically have better performance, especially if you have many scripts + running. - If this function successfully kills the specified script, then it will return true. - Otherwise, it will return false. - *Examples:* + Example: - The following example will try to kill the script with the PID 10:: + .. code-block:: javascript if (kill(10)) { print("Killed script with PID 10!"); diff --git a/doc/source/netscript/basicfunctions/killall.rst b/doc/source/netscript/basicfunctions/killall.rst index 5e1cd87a0..305921fa9 100644 --- a/doc/source/netscript/basicfunctions/killall.rst +++ b/doc/source/netscript/basicfunctions/killall.rst @@ -1,10 +1,17 @@ killall() Netscript Function ============================ -.. js:function:: killall(hostname/ip) +.. js:function:: killall(hostname) - :param string hostname/ip: IP or hostname of the server on which to kill all scripts :RAM cost: 0.5 GB + :param string hostname: Hostname of the server on which to kill all scripts. + :returns: ``true`` if scripts were killed on target server. - Kills all running scripts on the specified server. This function returns true if any scripts were killed, and - false otherwise. In other words, it will return true if there are any scripts running on the target server. + Kills all running scripts on the specified server. + + + Example: + + .. code-block:: javascript + + killall('foodnstuff'); // returns: true \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/ls.rst b/doc/source/netscript/basicfunctions/ls.rst index 7ffdc1fd9..27fda79b6 100644 --- a/doc/source/netscript/basicfunctions/ls.rst +++ b/doc/source/netscript/basicfunctions/ls.rst @@ -1,11 +1,15 @@ ls() Netscript Function ======================= -.. js:function:: ls(hostname/ip, [grep]) +.. js:function:: ls(hostname[, grep]) - :param string hostname/ip: Hostname or IP of the target server - :param string grep: a substring to search for in the filename :RAM cost: 0.2 GB + :param string hostname: Hostname of the target server. + :param string grep: a substring to search for in the filename. + :returns: String array of all files in alphabetical order. - Returns an array with the filenames of all files on the specified server (as strings). The returned array - is sorted in alphabetic order + Example: + + .. code-block:: javascript + + ls("home"); // returns: ["demo.script", "msg1.txt"] \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/nFormat.rst b/doc/source/netscript/basicfunctions/nFormat.rst index 9f634e1d5..2f1f86281 100644 --- a/doc/source/netscript/basicfunctions/nFormat.rst +++ b/doc/source/netscript/basicfunctions/nFormat.rst @@ -3,18 +3,20 @@ nFormat() Netscript Function .. js:function:: nFormat(n, format) - :param number n: Number to format - :param string format: Formatter :RAM cost: 0 GB + :param number n: number to format + :param string format: The format to use. - Converts a number into a string with the specified formatter. This uses the - `numeraljs `_ library, so the formatters must be compatible - with that. + Converts a number into a string with the specified format. This uses the + `numeraljs `_ library, so the formatters must be + compatible with that. - This is the same function that the game itself uses to display numbers. + The game uses the ``$0.000a`` format to display money. - Examples:: + Example: - nFormat(1.23e9, "$0.000a"); // Returns "$1.230b" - nFormat(12345.678, "0,0"); // Returns "12,346" - nFormat(0.84, "0.0%"); // Returns "84.0% + .. code-block:: javascript + + nFormat(1.23e9, "$0.000a"); // returns: "$1.230b" + nFormat(12345.678, "0,0"); // returns: "12,346" + nFormat(0.84, "0.0%"); // returns: "84.0%" diff --git a/doc/source/netscript/basicfunctions/nuke.rst b/doc/source/netscript/basicfunctions/nuke.rst index e42807d40..4e53e3161 100644 --- a/doc/source/netscript/basicfunctions/nuke.rst +++ b/doc/source/netscript/basicfunctions/nuke.rst @@ -1,13 +1,16 @@ nuke() Netscript Function ========================= -.. js:function:: nuke(hostname/ip) +.. js:function:: nuke(hostname) - :param string hostname/ip: IP or hostname of the target server :RAM cost: 0.05 GB + :param string hostname: Hostname of the target server. Runs the NUKE.exe program on the target server. NUKE.exe must exist on your home computer. - Example:: + + Example: + + .. code-block:: javascript nuke("foodnstuff"); diff --git a/doc/source/netscript/basicfunctions/peek.rst b/doc/source/netscript/basicfunctions/peek.rst index c118f4307..9a44bfa0d 100644 --- a/doc/source/netscript/basicfunctions/peek.rst +++ b/doc/source/netscript/basicfunctions/peek.rst @@ -3,10 +3,12 @@ peek() Netscript Function .. js:function:: peek(port) - :param number port: Port to peek. Must be an integer between 1 and 20 :RAM cost: 1 GB + :param number port: Port to peek. Must be an integer between 1 and 20. + :returns: First element on that port. - This function is used to peek at the data from a port. It returns the first element in the specified port - without removing that element. If the port is empty, the string "NULL PORT DATA" will be returned. + This function is used to peek at the data from a port. It returns the first + element in the specified port without removing that element. If the port is + empty, the string "NULL PORT DATA" will be returned. Read about how :ref:`netscript_ports` work here diff --git a/doc/source/netscript/basicfunctions/print.rst b/doc/source/netscript/basicfunctions/print.rst index b50ec4666..761efd598 100644 --- a/doc/source/netscript/basicfunctions/print.rst +++ b/doc/source/netscript/basicfunctions/print.rst @@ -3,7 +3,13 @@ print() Netscript Function .. js:function:: print(x) - :param x: Value to be printed :RAM cost: 0 GB + :param x: Value to be printed. Prints a value or a variable to the script's logs. + + Example: + + .. code-block:: javascript + + print("Hello world!"); // Prints "Hello world!" in the logs. \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/prompt.rst b/doc/source/netscript/basicfunctions/prompt.rst index 24c2cc7cf..da651ac90 100644 --- a/doc/source/netscript/basicfunctions/prompt.rst +++ b/doc/source/netscript/basicfunctions/prompt.rst @@ -3,8 +3,21 @@ prompt() Netscript Function .. js:function:: prompt(txt) - :param string txt: Text to appear in the prompt dialog box :RAM cost: 0 GB + :param string txt: Text to appear in the prompt dialog box. + :returns: ``true`` if the player clicks "Yes". - Prompts the player with a dialog box with two options: "Yes" and "No". This function will return true if the player click "Yes" and - false if the player clicks "No". The script's execution is halted until the player selects one of the options. + Prompts the player with a dialog box with two options: "Yes" and "No". This + function will return true if the player click "Yes" and false if the player + clicks "No". The script's execution is halted until the player selects one + of the options. + + Example: + + .. code-block:: javascript + + cost = getPurchasedServerCost(8192); + answer = prompt("Buy a server for $"+cost); + if(answer) { + purchaseServer("my server", 8192); + } \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/ps.rst b/doc/source/netscript/basicfunctions/ps.rst index fcdf2583a..a5cdbaf81 100644 --- a/doc/source/netscript/basicfunctions/ps.rst +++ b/doc/source/netscript/basicfunctions/ps.rst @@ -1,28 +1,29 @@ ps() Netscript Function ======================= -.. js:function:: ps(hostname/ip=current ip) +.. js:function:: ps([hostname=current hostname]) - :param string ip: Hostname or IP address of the target server. - If not specified, it will be the current server's IP by default :RAM cost: 0.2 GB + :param string hostname: Hostname address of the target server. + If not specified, it will be the current server's IP by default. + :returns: array of object - Returns an array with general information about all scripts running on the specified - target server. The information for each server is given in an object with - the following structure:: + Returns an array with general information about all scripts running on the + specified target server. The information for each server is given in an + object with the following structure:: { - filename: Script name, - threads: Number of threads script is running with, - args: Script's arguments + filename: Script name, + threads: Number of threads script is running with, + args: Script's arguments } - Example usage (using :ref:`netscriptjs`):: + Example: - export async function main(ns) { - const ps = ns.ps("home"); - for (let i = 0; i < ps.length; ++i) { - ns.tprint(ps[i].filename + ' ' + ps[i].threads); - ns.tprint(ps[i].args); - } + .. code-block:: javascript + + processes = ps("home"); + for (let i = 0; i < ps.length; ++i) { + tprint(ps[i].filename + ' ' + ps[i].threads); + tprint(ps[i].args); } diff --git a/doc/source/netscript/basicfunctions/purchaseServer.rst b/doc/source/netscript/basicfunctions/purchaseServer.rst index 91052c33b..c2ac2d44f 100644 --- a/doc/source/netscript/basicfunctions/purchaseServer.rst +++ b/doc/source/netscript/basicfunctions/purchaseServer.rst @@ -3,25 +3,29 @@ purchaseServer() Netscript Function .. js:function:: purchaseServer(hostname, ram) - :param string hostname: Hostname of the purchased server - :param number ram: Amount of RAM of the purchased server. Must be a power of 2. Maximum value of :js:func:`getPurchasedServerMaxRam` :RAM cost: 2.25 GB + :param string hostname: Hostname of the purchased server. + :param number ram: Amount of RAM of the purchased server. Must be a power of + 2. Maximum value of :doc:`getPurchasedServerMaxRam` + :returns: The hostname of the newly purchased server. Purchased a server with the specified hostname and amount of RAM. - The *hostname* argument can be any data type, but it will be converted to a string and have whitespace removed. Anything that resolves to an empty string will - cause the function to fail. If there is already a server with the specified hostname, then the function will automatically append - a number at the end of the *hostname* argument value until it finds a unique hostname. For example, if the script calls - *purchaseServer("foo", 4)* but a server named "foo" already exists, the it will automatically change the hostname to "foo-0". If there is already - a server with the hostname "foo-0", then it will change the hostname to "foo-1", and so on. + The ``hostname`` argument can be any data type, but it will be converted to + a string and have whitespace removed. Anything that resolves to an empty + string will cause the function to fail. If there is already a server with + the specified hostname, then the function will automatically append a number + at the end of the ``hostname`` argument value until it finds a unique + hostname. For example, if the script calls ``purchaseServer("foo", 4)`` but + a server named "foo" already exists, the it will automatically change the + hostname to "foo-0". If there is already a server with the hostname "foo-0", + then it will change the hostname to "foo-1", and so on. Note that there is a maximum limit to the amount of servers you can purchase. - Returns the hostname of the newly purchased server as a string. If the function fails to purchase a server, then it will return an - empty string. The function will fail if the arguments passed in are invalid, if the player does not have enough money to purchase - the specified server, or if the player has exceeded the maximum amount of servers. + Example: - Example:: + .. code-block:: javascript ram = 64; hn = "pserv-"; diff --git a/doc/source/netscript/basicfunctions/read.rst b/doc/source/netscript/basicfunctions/read.rst index 21f1cd693..b1cf5ca77 100644 --- a/doc/source/netscript/basicfunctions/read.rst +++ b/doc/source/netscript/basicfunctions/read.rst @@ -1,16 +1,21 @@ read() Netscript Function ========================= -.. js:function:: read(port/fn) +.. js:function:: read(portOrFilename) - :param string/number port/fn: Port or text file to read from :RAM cost: 1 GB + :param string/number portOrFilename: Port or text file to read from. - This function is used to read data from a port, a text file (.txt), or a script (.script, .js, .ns) + This function is used to read data from a port, a text file (.txt), or a + script (.script, .js, .ns). - If the argument *port/fn* is a number between 1 and 20, then it specifies a port and it will read data from that port. Read - about how :ref:`netscript_ports` work here. A port is a serialized queue. This function - will remove the first element from that queue and return it. If the queue is empty, then the string "NULL PORT DATA" will be returned. + If the argument ``portOrFilename`` is a number between 1 and 20, then it + specifies a port and it will read data from that port. Read about how + :ref:`netscript_ports` work here. A port is a serialized queue. This + function will remove the first element from that queue and return it. If the + queue is empty, then the string "NULL PORT DATA" will be returned. - If the argument *port/fn* is a string, then it specifies the name of a text file or script and this function will return the data in the specified text file/script. If - the text file does not exist, an empty string will be returned. + If the argument ``portOrFilename`` is a string, then it specifies the name + of a text file or script and this function will return the data in the + specified text file/script. If the text file does not exist, an empty string + will be returned. diff --git a/doc/source/netscript/basicfunctions/relaysmtp.rst b/doc/source/netscript/basicfunctions/relaysmtp.rst index 457bbafa1..5081e54d8 100644 --- a/doc/source/netscript/basicfunctions/relaysmtp.rst +++ b/doc/source/netscript/basicfunctions/relaysmtp.rst @@ -1,13 +1,17 @@ relaysmtp() Netscript Function ============================== -.. js:function:: relaysmtp(hostname/ip) +.. js:function:: relaysmtp(hostname) - :param string hostname/ip: IP or hostname of the target server :RAM cost: 0.05 GB + :param string hostname: Hostname of the target server. - Runs the relaySMTP.exe program on the target server. relaySMTP.exe must exist on your home computer. - Example:: + Runs the relaySMTP.exe program on the target server. relaySMTP.exe must + exist on your home computer. + + Example: + + .. code-block:: javascript relaysmtp("foodnstuff"); diff --git a/doc/source/netscript/basicfunctions/rm.rst b/doc/source/netscript/basicfunctions/rm.rst index e5c64bdfc..a1159cff8 100644 --- a/doc/source/netscript/basicfunctions/rm.rst +++ b/doc/source/netscript/basicfunctions/rm.rst @@ -1,11 +1,13 @@ rm() Netscript Function ======================= -.. js:function:: rm(fn[, hostname/ip=current server]) +.. js:function:: rm(filename[, hostname=current server]) - :param string fn: Filename of file to remove. Must include the extension - :param string hostname/ip: Hostname or IP Address of the server on which to delete the file. Optional. Defaults to current server - :returns: True if it successfully deletes the file, and false otherwise :RAM cost: 1 GB + :param string filename: Filename of file to remove. Must include the extension. + :param string hostname: Hostname address of the server on which to delete + the file. Optional. Defaults to current server + :returns: ``true`` if it successfully deletes the file. - Removes the specified file from the current server. This function works for every file type except message (.msg) files. + Removes the specified file from the current server. This function works for + every file type except ``.msg`` files. diff --git a/doc/source/netscript/basicfunctions/run.rst b/doc/source/netscript/basicfunctions/run.rst index 21f7fbe91..b7ef167e6 100644 --- a/doc/source/netscript/basicfunctions/run.rst +++ b/doc/source/netscript/basicfunctions/run.rst @@ -1,38 +1,44 @@ run() Netscript Function ======================== -.. js:function:: run(script, [numThreads=1], [args...]) +.. js:function:: run(script[, numThreads=1[, args...]]) - :param string script: Filename of script to run - :param number numThreads: Optional thread count for new script. Set to 1 by default. Will be rounded to nearest integer - :param args...: - Additional arguments to pass into the new script that is being run. Note that if any arguments are being - passed into the new script, then the second argument *numThreads* must be filled in with a value. :RAM cost: 1 GB + :param string script: Filename of script to run + :param number numThreads: Optional thread count for new script. Set to 1 by + default. Will be rounded to nearest integer. + :param args...: + Additional arguments to pass into the new script that is being run. Note + that if any arguments are being passed into the new script, then the + second argument ``numThreads`` must be filled in with a value. + :returns: The process id of the new process or 0 on failure. - Run a script as a separate process. This function can only be used to run scripts located on the current server (the server - running the script that calls this function). + Run a script as a separate process. This function can only be used to run + scripts located on the current server (the server running the script that + calls this function). - If the script was successfully started, then this functions returns the PID - of that script. Otherwise, it returns 0. + .. warning:: Running this function with a ``numThreads`` argument of 0 will + return 0 without running the script. However, running this function with + a negative ``numThreads`` argument will cause a runtime error. - .. note:: PID stands for Process ID. The PID is a unique identifier for each script. - The PID will always be a positive integer. + The simplest way to use the :doc:`run` command is to call it with just + the script name. The following example will run ``foo.script`` + single-threaded with no arguments: - .. warning:: Running this function with a *numThreads* argument of 0 will return 0 without - running the script. However, running this function with a negative *numThreads* - argument will cause a runtime error. - - The simplest way to use the *run* command is to call it with just the script name. The following example will run - 'foo.script' single-threaded with no arguments:: + .. code-block:: javascript run("foo.script"); - The following example will run 'foo.script' but with 5 threads instead of single-threaded:: + The following example will run 'foo.script' but with 5 threads instead of + single-threaded: + + .. code-block:: javascript run("foo.script", 5); - This next example will run 'foo.script' single-threaded, and will pass the string 'foodnstuff' into the script - as an argument:: + This next example will run ``foo.script`` single-threaded, and will pass the + string ``foodnstuff`` into the script as an argument: + + .. code-block:: javascript run("foo.script", 1, 'foodnstuff'); diff --git a/doc/source/netscript/basicfunctions/scan.rst b/doc/source/netscript/basicfunctions/scan.rst index a3412d260..1db16bc3f 100644 --- a/doc/source/netscript/basicfunctions/scan.rst +++ b/doc/source/netscript/basicfunctions/scan.rst @@ -1,11 +1,15 @@ scan() Netscript Function ========================= -.. js:function:: scan(hostname/ip=current ip[, hostnames=true]) +.. js:function:: scan(hostname=current hostname) - :param string hostname/ip: IP or hostname of the server to scan - :param boolean: Optional boolean specifying whether the function should output hostnames (if true) or IP addresses (if false) :RAM cost: 0.2 GB + :param string hostname: Hostname of the server to scan. + :returns: array of strings of all the host directly connected to the target + server. - Returns an array containing the hostnames or IPs of all servers that are one node way from the specified target server. The - hostnames/IPs in the returned array are strings. + Example: + + .. code-block:: javascript + + scan("home"); // returns: ["foodnstuff", "sigma-cosmetics", "joesguns", "hong-fang-tea", "harakiri-sushi", "iron-gym"] \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/scp.rst b/doc/source/netscript/basicfunctions/scp.rst index a290083fa..93a8436a3 100644 --- a/doc/source/netscript/basicfunctions/scp.rst +++ b/doc/source/netscript/basicfunctions/scp.rst @@ -1,29 +1,33 @@ scp() Netscript Function ======================== -.. js:function:: scp(files, [source], destination) +.. js:function:: scp(files[, source], destination) + :RAM cost: 0.6 GB :param string/array files: Filename or an array of filenames of script/literature files to copy :param string source: - Hostname or IP of the source server, which is the server from which the file will be copied. + Hostname of the source server, which is the server from which the file will be copied. This argument is optional and if it's omitted the source will be the current server. - :param string destination: Hostname or IP of the destination server, which is the server to which the file will be copied. - :RAM cost: 0.6 GB + :param string destination: Hostname of the destination server, which is the server to which the file will be copied. + :returns: ``true`` is the copy was a success. - Copies a script or literature (.lit) file(s) to another server. The *files* argument can be either a string specifying a - single file to copy, or an array of strings specifying multiple files to copy. + Copies a script or literature (.lit) file(s) to another server. The + ``files`` argument can be either a string specifying a single file to copy, + or an array of strings specifying multiple files to copy. - Returns true if the script/literature file is successfully copied over and false otherwise. If the *files* argument is an array - then this function will return true if at least one of the files in the array is successfully copied. + If the ``files`` argument is an array then this function will return true if + at least one of the files in the array is successfully copied. - Examples:: + Example: - //Copies hack-template.script from the current server to foodnstuff - scp("hack-template.script", "foodnstuff"); + .. code-block:: javascript - //Copies foo.lit from the helios server to the home computer - scp("foo.lit", "helios", "home"); + //Copies "hack-template.script" from the current server to "foodnstuff" + scp("hack-template.script", "foodnstuff"); // returns: true - //Tries to copy three files from rothman-uni to home computer + //Copies "foo.lit" from the helios server to the "home" computer + scp("foo.lit", "helios", "home"); // returns: true + + //Tries to copy three files from "rothman-uni" to "home" computer files = ["foo1.lit", "foo2.script", "foo3.script"]; - scp(files, "rothman-uni", "home"); + scp(files, "rothman-uni", "home"); // returns: true diff --git a/doc/source/netscript/basicfunctions/scriptKill.rst b/doc/source/netscript/basicfunctions/scriptKill.rst index 767e48322..a3fd5729d 100644 --- a/doc/source/netscript/basicfunctions/scriptKill.rst +++ b/doc/source/netscript/basicfunctions/scriptKill.rst @@ -1,11 +1,18 @@ scriptKill() Netscript Function =============================== -.. js:function:: scriptKill(scriptname, hostname/ip) +.. js:function:: scriptKill(scriptname, hostname) - :param string scriptname: Filename of script to kill. This is case-sensitive. - :param string hostname/ip: Hostname or IP of target server :RAM cost: 1 GB + :param string scriptname: Filename of script to kill. case-sensitive. + :param string hostname: Hostname of target server. + :returns: ``true`` if any scripts were killed. - Kills all scripts with the specified filename on the target server specified by *hostname/ip*, regardless of arguments. Returns - true if one or more scripts were successfully killed, and false if none were. + Kills all scripts with the specified filename on the target server specified + by ``hostname``, regardless of arguments. + + Example: + + .. code-block:: javascript + + scriptKill("demo.script"); // returns: true diff --git a/doc/source/netscript/basicfunctions/scriptRunning.rst b/doc/source/netscript/basicfunctions/scriptRunning.rst index a384ea35e..9d4ff91c5 100644 --- a/doc/source/netscript/basicfunctions/scriptRunning.rst +++ b/doc/source/netscript/basicfunctions/scriptRunning.rst @@ -1,24 +1,30 @@ scriptRunning() Netscript Function ================================== -.. js:function:: scriptRunning(scriptname, hostname/ip) +.. js:function:: scriptRunning(scriptname, hostname) - :param string scriptname: Filename of script to check. This is case-sensitive. - :param string hostname/ip: Hostname or IP of target server :RAM cost: 1 GB + :param string scriptname: Filename of script to check. case-sensitive. + :param string hostname: Hostname of target server. + :returns: ``true`` if any script with that file name is running on that + server. - Returns a boolean indicating whether any instance of the specified script is running on the target server, regardless of - its arguments. + This is different than the :doc:`isRunning` function because it + does not try to identify a specific instance of a running script by its + arguments. - This is different than the *isRunning()* function because it does not try to identify a specific instance of a running script - by its arguments. + Examples: - **Examples:** + The example below will return true if there is any script named + ``foo.script`` running on the ``foodnstuff`` server, and false otherwise: - The example below will return true if there is any script named *foo.script* running on the *foodnstuff* server, and false otherwise:: + .. code-block:: javascript scriptRunning("foo.script", "foodnstuff"); - The example below will return true if there is any script named "foo.script" running on the current server, and false otherwise:: + The example below will return true if there is any script named + ``foo.script`` running on the current server, and false otherwise: + + .. code-block:: javascript scriptRunning("foo.script", getHostname()); diff --git a/doc/source/netscript/basicfunctions/serverExists.rst b/doc/source/netscript/basicfunctions/serverExists.rst index c32dab411..76a8f6228 100644 --- a/doc/source/netscript/basicfunctions/serverExists.rst +++ b/doc/source/netscript/basicfunctions/serverExists.rst @@ -1,9 +1,14 @@ serverExists() Netscript Function ================================= -.. js:function:: serverExists(hostname/ip) +.. js:function:: serverExists(hostname) - :param string hostname/ip: Hostname or IP of target server :RAM cost: 0.1 GB + :param string hostname: Hostname of target server. + :returns: ``true`` if the target server exists. - Returns a boolean denoting whether or not the specified server exists + Example: + + .. code-block:: javascript + + serverExists("foodnstuff"); // returns: true \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/sleep.rst b/doc/source/netscript/basicfunctions/sleep.rst index b9109a9cb..d46c176dd 100644 --- a/doc/source/netscript/basicfunctions/sleep.rst +++ b/doc/source/netscript/basicfunctions/sleep.rst @@ -3,7 +3,14 @@ sleep() Netscript Function .. js:function:: sleep(n) - :param number n: Number of milliseconds to sleep :RAM cost: 0 GB + :param number n: Number of milliseconds to sleep Suspends the script for n milliseconds. + + + Example: + + .. code-block:: javascript + + sleep(3000); // Will wait 3 seconds. \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/spawn.rst b/doc/source/netscript/basicfunctions/spawn.rst index d16fe2f60..538bf39e2 100644 --- a/doc/source/netscript/basicfunctions/spawn.rst +++ b/doc/source/netscript/basicfunctions/spawn.rst @@ -1,20 +1,24 @@ spawn() Netscript Function ========================== -.. js:function:: spawn(script, numThreads, [args...]) +.. js:function:: spawn(script, numThreads[, args...]) + :RAM cost: 2 GB :param string script: Filename of script to execute - :param number numThreads: Number of threads to spawn new script with. Will be rounded to nearest integer + :param number numThreads: Number of threads to spawn new script with. Will + be rounded to nearest integer. :param args...: Additional arguments to pass into the new script that is being run. - :RAM cost: 2 GB - Terminates the current script, and then after a delay of about 10 seconds it will execute the newly-specified script. - The purpose of this function is to execute a new script without being constrained by the RAM usage of the current one. - This function can only be used to run scripts on the local server. + Terminates the current script, and then after a delay of about 10 seconds it + will execute the newly-specified script. The purpose of this function is to + execute a new script without being constrained by the RAM usage of the + current one. This function can only be used to run scripts on the local + server. - Because this function immediately terminates the script, it does not have a return value. - The following example will execute the script 'foo.script' with 10 threads and the arguments 'foodnstuff' and 90:: + Example: - spawn('foo.script', 10, 'foodnstuff', 90); + .. code-block:: javascript + + spawn('foo.script', 10, 'foodnstuff', 90); // "run foo.script 10 foodnstuff 90" in 10 seconds. diff --git a/doc/source/netscript/basicfunctions/sqlinject.rst b/doc/source/netscript/basicfunctions/sqlinject.rst index 678371cb1..24ee86142 100644 --- a/doc/source/netscript/basicfunctions/sqlinject.rst +++ b/doc/source/netscript/basicfunctions/sqlinject.rst @@ -1,13 +1,16 @@ sqlinject() Netscript Function ============================== -.. js:function:: sqlinject(hostname/ip) +.. js:function:: sqlinject(hostname) - :param string hostname/ip: IP or hostname of the target server :RAM cost: 0.05 GB + :param string hostname: Hostname of the target server. - Runs the SQLInject.exe program on the target server. SQLInject.exe must exist on your home computer. + Runs the SQLInject.exe program on the target server. SQLInject.exe must + exist on your home computer. - Example:: + Example: + + .. code-block:: javascript sqlinject("foodnstuff"); diff --git a/doc/source/netscript/basicfunctions/tail.rst b/doc/source/netscript/basicfunctions/tail.rst index 18e32a9c1..75cb8df9e 100644 --- a/doc/source/netscript/basicfunctions/tail.rst +++ b/doc/source/netscript/basicfunctions/tail.rst @@ -1,23 +1,25 @@ tail() Netscript Function ================================== -.. js:function:: tail([fn], [hostname/ip=current ip], [...args]) +.. js:function:: tail([fn[, hostname=current hostname[, [...args]]]) - :param string fn: Optional. Filename of script to get logs from. - :param string ip: Optional. IP or hostname of the server that the script is on - :param args...: Arguments to identify which scripts to get logs for :RAM cost: 0 GB + :param string fn: Optional. Filename of script to get logs from. + :param string hostname: Optional. Hostname of the server that the script is on. + :param args...: Arguments to identify which scripts to get logs for. Opens a script's logs. This is functionally the same as the :ref:`tail_terminal_command` Terminal command. If the function is called with no arguments, it will open the current script's logs. - Otherwise, the `fn`, `hostname/ip,` and `args...` arguments can be used to get the logs - from another script. Remember that scripts are uniquely identified by both - their names and arguments. + Otherwise, the ``fn``, ``hostname``, and ``args...`` arguments can be + used to get the logs from another script. Remember that scripts are uniquely + identified by both their names and arguments. - Examples:: + Example: + + .. code-block:: javascript // Open logs from foo.script on the current server that was run with no args tail("foo.script"); diff --git a/doc/source/netscript/basicfunctions/tprint.rst b/doc/source/netscript/basicfunctions/tprint.rst index 271879c30..a502bf3e2 100644 --- a/doc/source/netscript/basicfunctions/tprint.rst +++ b/doc/source/netscript/basicfunctions/tprint.rst @@ -3,7 +3,13 @@ tprint() Netscript Function .. js:function:: tprint(x) - :param x: Value to be printed :RAM cost: 0 GB + :param x: Value to be printed - Prints a value or a variable to the Terminal + Prints a value or a variable to the Terminal. + + Example: + + .. code-block:: javascript + + tprint("Hello world!"); // Prints "Hello world!" to the terminal. \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/tryWrite.rst b/doc/source/netscript/basicfunctions/tryWrite.rst index 3c9a54e84..2264c466c 100644 --- a/doc/source/netscript/basicfunctions/tryWrite.rst +++ b/doc/source/netscript/basicfunctions/tryWrite.rst @@ -3,10 +3,12 @@ tryWrite() Netscript Function .. js:function:: tryWrite(port, data="") + :RAM cost: 1 GB :param number port: Port to be written to :param string data: Data to try to write - :returns: True if the data is successfully written to the port, and false otherwise - :RAM cost: 1 GB + :returns: ``true`` if the data is successfully written to the port. - Attempts to write data to the specified Netscript Port. If the port is full, the data will - not be written. Otherwise, the data will be written normally + Attempts to write data to the specified Netscript Port. If the port is full, + the data will not be written. Otherwise, the data will be written normally. + + See :ref:`netscript_ports` for more details. \ No newline at end of file diff --git a/doc/source/netscript/basicfunctions/weaken.rst b/doc/source/netscript/basicfunctions/weaken.rst index 2d67ddccc..db87afb79 100644 --- a/doc/source/netscript/basicfunctions/weaken.rst +++ b/doc/source/netscript/basicfunctions/weaken.rst @@ -1,26 +1,31 @@ weaken() Netscript Function =========================== -.. js:function:: weaken(hostname/ip[, opts={}]) +.. js:function:: weaken(hostname[, opts={}]) - :param string hostname/ip: IP or hostname of the target server to weaken + :RAM cost: 0.15 GB + :param string hostname: Hostname of the target server to weaken. :param object opts: Optional parameters for configuring function behavior. Properties: * threads (*number*) - Number of threads to use for this function. Must be less than or equal to the number of threads the script is running with. + :returns: The amount by which the target server's security level was + decreased. This is equivalent to 0.05 multiplied by the number of script + threads. - :returns: The amount by which the target server's security level was decreased. This is equivalent to 0.05 multiplied - by the number of script threads - :RAM cost: 0.15 GB + Use your hacking skills to attack a server's security, lowering the server's + security level. The runtime for this command depends on your hacking level + and the target server's security level. This function lowers the security + level of the target server by 0.05. - Use your hacking skills to attack a server's security, lowering the server's security level. The runtime for this command - depends on your hacking level and the target server's security level. This function lowers the security level of the target - server by 0.05. + Like :doc:`hack` and :doc:`grow`, :doc:`weaken` can be + called on any server, regardless of where the script is running. This + command requires root access to the target server, but there is no required + hacking level to run the command. - Like hack() and grow(), weaken() can be called on any server, regardless of where the script is running. This command requires - root access to the target server, but there is no required hacking level to run the command. + Example: - Example:: + .. code-block:: javascript weaken("foodnstuff"); weaken("foodnstuff", { threads: 5 }); // Only use 5 threads to weaken diff --git a/doc/source/netscript/basicfunctions/wget.rst b/doc/source/netscript/basicfunctions/wget.rst index 78db9950e..423387a78 100644 --- a/doc/source/netscript/basicfunctions/wget.rst +++ b/doc/source/netscript/basicfunctions/wget.rst @@ -1,12 +1,12 @@ wget() Netscript Function ========================= -.. js:function:: wget(url, target[, hostname/ip=current ip]) +.. js:function:: wget(url, target[, hostname=current hostname]) + :RAM cost: 0 GB :param string url: URL to pull data from :param string target: Filename to write data to. Must be script or text file - :param string ip: Optional hostname/ip of server for target file. - :RAM cost: 0 GB + :param string ip: Optional hostname of server for target file. Retrieves data from a URL and downloads it to a file on the specified server. The data can only be downloaded to a script (.script, .ns, .js) or a text file (.txt). If the file already exists, @@ -20,12 +20,12 @@ wget() Netscript Function **IMPORTANT:** This is an asynchronous function that returns a Promise. The Promise's resolved value will be a boolean indicating whether or not the data was successfully retrieved from the URL. Because the function is async and returns a Promise, - it is recommended you use :code:`wget` in :ref:`netscriptjs`. + it is recommended you use ``wget`` in :ref:`netscriptjs`. In NetscriptJS, you must preface any call to - :code:`wget` with the :code:`await` keyword (like you would :code:`hack` or :code:`sleep`). + ``wget`` with the ``await`` keyword (like you would ``hack`` or ``sleep``). - :code:`wget` will still work in :ref:`netscript1`, but the functions execution will not + ``wget`` will still work in :ref:`netscript1`, but the functions execution will not be synchronous (i.e. it may not execute when you expect/want it to). Furthermore, since Promises are not - supported in ES5, you will not be able to process the returned value of :code:`wget` in + supported in ES5, you will not be able to process the returned value of ``wget`` in Netscript 1.0. diff --git a/doc/source/netscript/basicfunctions/write.rst b/doc/source/netscript/basicfunctions/write.rst index c492ea51d..497e8b54c 100644 --- a/doc/source/netscript/basicfunctions/write.rst +++ b/doc/source/netscript/basicfunctions/write.rst @@ -1,20 +1,27 @@ write() Netscript Function =========================== -.. js:function:: write(port/fn, data="", mode="a") +.. js:function:: write(portOrFilename, data="", mode="a") - :param string/number port/fn: Port or text file/script that will be written to + :RAM cost: 1 GB + :param string/number portOrFilename: Port or text file/script that will be written to :param string data: Data to write :param string mode: Defines the write mode. Only valid when writing to text files or scripts. - :RAM cost: 1 GB - This function can be used to either write data to a port, a text file (.txt), or a script (.script, .js, .ns) - If the first argument is a number between 1 and 20, then it specifies a port and this function will write *data* to that port. Read - about how :ref:`netscript_ports` work here. The third argument, *mode*, is not used + This function can be used to either write data to a port, a text file + (.txt), or a script (.script, .js, .ns) + + If the first argument is a number between 1 and 20, then it specifies a port + and this function will write ``data`` to that port. Read about how + :ref:`netscript_ports` work here. The third argument, ``mode``, is not used when writing to a port. - If the first argument is a string, then it specifies the name of a text file or script and this function will write *data* to that text file/script. If the - specified text file/script does not exist, then it will be created. The third argument *mode*, defines how the data will be written. If *mode* - is set to "w", then the data is written in "write" mode which means that it will overwrite all existing data on the text file/script. If *mode* is set to - any other value then the data will be written in "append" mode which means that the data will be added at the end of the file. + If the first argument is a string, then it specifies the name of a text file + or script and this function will write ``data`` to that text file/script. If + the specified text file/script does not exist, then it will be created. The + third argument ``mode``, defines how the data will be written. If ``mode`` + is set to "w", then the data is written in "write" mode which means that it + will overwrite all existing data on the text file/script. If ``mode`` is set + to any other value then the data will be written in "append" mode which + means that the data will be added at the end of the file. diff --git a/doc/source/netscript/bladeburnerapi/getActionAutolevel.rst b/doc/source/netscript/bladeburnerapi/getActionAutolevel.rst index 7e49939f6..b2dc609ec 100644 --- a/doc/source/netscript/bladeburnerapi/getActionAutolevel.rst +++ b/doc/source/netscript/bladeburnerapi/getActionAutolevel.rst @@ -4,10 +4,12 @@ getActionAutolevel() Netscript Function .. js:function:: getActionAutolevel(type, name) :RAM cost: 4 GB - :param string type: Type of action. See :ref:`bladeburner_action_types` :param string name: Name of action. Must be an exact match + :returns: ``true`` if this action is set to auto level. - Return a boolean indicating whether or not this action is currently set to autolevel. + Examples: - Returns false if an invalid action is specified. + .. code-block:: javascript + + bladeburner.getActionAutolevel("Contracts", "Tracking"); // returns: true \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/getActionCountRemaining.rst b/doc/source/netscript/bladeburnerapi/getActionCountRemaining.rst index a1938bb9e..2e658118c 100644 --- a/doc/source/netscript/bladeburnerapi/getActionCountRemaining.rst +++ b/doc/source/netscript/bladeburnerapi/getActionCountRemaining.rst @@ -4,12 +4,18 @@ getActionCountRemaining() Netscript Function .. js:function:: getActionCountRemaining(type, name) :RAM cost: 4 GB - :param string type: Type of action. See :ref:`bladeburner_action_types` :param string name: Name of action. Must be an exact match + :returns: Remaining action count. -1 for invalid actions. - Returns the remaining count of the specified action. + Note that this is meant to be used for 'Contracts' and 'Operations'. + This function will return 'Infinity' for actions such as 'Training' and + 'Field Analysis'. + This function will return 1 for BlackOps not yet completed regardless of + wether the player has the required rank to attempt the mission or not. - Note that this is meant to be used for Contracts and Operations. - This function will return 'Infinity' for actions such as Training and Field Analysis. - This function will return 1 for BlackOps not yet completed regardless of wether the player has the required rank to attempt the mission or not. + Example: + + .. code-block:: javascript + + bladeburner.getActionCountRemaining("Contracts", "Tracking"); // returns: 124 \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/getActionCurrentLevel.rst b/doc/source/netscript/bladeburnerapi/getActionCurrentLevel.rst index efb234e8a..c55faedb4 100644 --- a/doc/source/netscript/bladeburnerapi/getActionCurrentLevel.rst +++ b/doc/source/netscript/bladeburnerapi/getActionCurrentLevel.rst @@ -4,10 +4,12 @@ getActionCurrentLevel() Netscript Function .. js:function:: getActionCurrentLevel(type, name) :RAM cost: 4 GB - :param string type: Type of action. See :ref:`bladeburner_action_types` - :param string name: Name of action. Must be an exact match + :param string name: Name of action. Must be an exact match. + :returns: Action current level, -1 for invalid actions. - Returns the current level of this action. + Example: - Returns -1 if an invalid action is specified. + .. code-block:: javascript + + bladeburner.getActionCountRemaining("Contracts", "Tracking"); // returns: 7 \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/getActionEstimatedSuccessChance.rst b/doc/source/netscript/bladeburnerapi/getActionEstimatedSuccessChance.rst index 5ca773c2e..0677c180f 100644 --- a/doc/source/netscript/bladeburnerapi/getActionEstimatedSuccessChance.rst +++ b/doc/source/netscript/bladeburnerapi/getActionEstimatedSuccessChance.rst @@ -4,10 +4,12 @@ getActionEstimatedSuccessChance() Netscript Function .. js:function:: getActionEstimatedSuccessChance(type, name) :RAM cost: 4 GB - :param string type: Type of action. See :ref:`bladeburner_action_types` :param string name: Name of action. Must be an exact match + :returns: Estimated success chance in decimal - Returns the estimated success chance for the specified action. This chance - is returned as a decimal value, NOT a percentage (e.g. if you have an estimated - success chance of 80%, then this function will return 0.80, NOT 80). + Example: + + .. code-block:: javascript + + bladeburner.getActionEstimatedSuccessChance("Contracts", "Tracking"); // returns: .3 diff --git a/doc/source/netscript/bladeburnerapi/getActionMaxLevel.rst b/doc/source/netscript/bladeburnerapi/getActionMaxLevel.rst index a42bf7517..92b48f875 100644 --- a/doc/source/netscript/bladeburnerapi/getActionMaxLevel.rst +++ b/doc/source/netscript/bladeburnerapi/getActionMaxLevel.rst @@ -4,10 +4,12 @@ getActionMaxLevel() Netscript Function .. js:function:: getActionMaxLevel(type, name) :RAM cost: 4 GB - :param string type: Type of action. See :ref:`bladeburner_action_types` :param string name: Name of action. Must be an exact match + :returns: Action max level, -1 for invalid actions. - Returns the maximum level for this action. + Example: - Returns -1 if an invalid action is specified. + .. code-block:: javascript + + bladeburner.getActionMaxLevel("Contracts", "Tracking"); // returns: 15 diff --git a/doc/source/netscript/bladeburnerapi/getActionRepGain.rst b/doc/source/netscript/bladeburnerapi/getActionRepGain.rst index 2d9948a97..5bfeda64d 100644 --- a/doc/source/netscript/bladeburnerapi/getActionRepGain.rst +++ b/doc/source/netscript/bladeburnerapi/getActionRepGain.rst @@ -4,11 +4,15 @@ getActionRepGain() Netscript Function .. js:function:: getActionRepGain(type, name[, level=current level]) :RAM cost: 4 GB - :param string type: Type of action. See :ref:`bladeburner_action_types` :param string name: Name of action. Must be an exact match - :param number level: Optional action level at which to calculate the gain + :param number level: Optional action level at which to calculate the gain. + :returns: Average Bladeburner reputation gain for successfully completing + the specified action. Note that this value is an 'average' and the real + reputation gain may vary slightly from this value. - Returns the average Bladeburner reputation gain for successfully completing - the specified action. Note that this value is an 'average' and the real - reputation gain may vary slightly from this value. + Example: + + .. code-block:: javascript + + bladeburner.getActionRepGain("Contracts", "Tracking"); // returns: 341 \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/getActionTime.rst b/doc/source/netscript/bladeburnerapi/getActionTime.rst index 42df756fc..e89f39c4f 100644 --- a/doc/source/netscript/bladeburnerapi/getActionTime.rst +++ b/doc/source/netscript/bladeburnerapi/getActionTime.rst @@ -4,8 +4,13 @@ getActionTime() Netscript Function .. js:function:: getActionTime(type, name) :RAM cost: 4 GB - :param string type: Type of action. See :ref:`bladeburner_action_types` :param string name: Name of action. Must be an exact match + :returns: Number of seconds it takes to complete the specified action. - Returns the number of seconds it takes to complete the specified action + + Example: + + .. code-block:: javascript + + bladeburner.getActionTime("Contracts", "Tracking"); // returns: 4 diff --git a/doc/source/netscript/bladeburnerapi/getBlackOpNames.rst b/doc/source/netscript/bladeburnerapi/getBlackOpNames.rst index b95edd9bf..310cdf681 100644 --- a/doc/source/netscript/bladeburnerapi/getBlackOpNames.rst +++ b/doc/source/netscript/bladeburnerapi/getBlackOpNames.rst @@ -4,5 +4,10 @@ getBlackOpNames() Netscript Function .. js:function:: getBlackOpNames() :RAM cost: 0.4 GB + :returns: Array of strings containing the names of all Bladeburner Black Ops. - Returns an array of strings containing the names of all Bladeburner Black Ops + Example: + + .. code-block:: javascript + + bladeburner.getBlackOpNames(); // returns: ["Operation Typhoon"] \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/getBlackOpRank.rst b/doc/source/netscript/bladeburnerapi/getBlackOpRank.rst index 0aba8a3ad..850cef76c 100644 --- a/doc/source/netscript/bladeburnerapi/getBlackOpRank.rst +++ b/doc/source/netscript/bladeburnerapi/getBlackOpRank.rst @@ -4,9 +4,11 @@ getBlackOpRank() Netscript Function .. js:function:: getBlackOpRank(name) :RAM cost: 2 GB - :param string name: name of the BlackOp. Must be an exact match. + :returns: Rank required to complete this BlackOp. -1 for invalid BlackOp. - Returns the rank required to complete this BlackOp. + Example: - Returns -1 if an invalid action is specified. + .. code-block:: javascript + + bladeburner.getBlackOpRank("Operation Typhoon"); // returns: 2500 \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/getBonusTime.rst b/doc/source/netscript/bladeburnerapi/getBonusTime.rst index 9fdf7d3cc..fc693a68f 100644 --- a/doc/source/netscript/bladeburnerapi/getBonusTime.rst +++ b/doc/source/netscript/bladeburnerapi/getBonusTime.rst @@ -4,8 +4,7 @@ getBonusTime() Netscript Function .. js:function:: getBonusTime() :RAM cost: 0 GB - - Returns the amount of accumulated "bonus time" (seconds) for the Bladeburner mechanic. + :returns: Amount of accumulated "bonus time" (seconds) for the Bladeburner mechanic. "Bonus time" is accumulated when the game is offline or if the game is inactive in the browser. @@ -14,3 +13,9 @@ getBonusTime() Netscript Function For example, if an action takes 30 seconds to complete but you've accumulated over 30 seconds in bonus time, then the action will only take 6 seconds in real life to complete. + + Example: + + .. code-block:: javascript + + bladeburner.getBonusTime(); // returns: 130 diff --git a/doc/source/netscript/bladeburnerapi/getCity.rst b/doc/source/netscript/bladeburnerapi/getCity.rst index cdc2d775e..49a6bd1b9 100644 --- a/doc/source/netscript/bladeburnerapi/getCity.rst +++ b/doc/source/netscript/bladeburnerapi/getCity.rst @@ -4,5 +4,10 @@ getCity() Netscript Function .. js:function:: getCity() :RAM cost: 4 GB + :returns: City that the player is currently in (for Bladeburner). - Returns the city that the player is currently in (for Bladeburner). + Example: + + .. code-block:: javascript + + bladeburner.getCity(); // returns: "Sector-12" diff --git a/doc/source/netscript/bladeburnerapi/getCityChaos.rst b/doc/source/netscript/bladeburnerapi/getCityChaos.rst index 77fb0b073..e17fa7d8b 100644 --- a/doc/source/netscript/bladeburnerapi/getCityChaos.rst +++ b/doc/source/netscript/bladeburnerapi/getCityChaos.rst @@ -4,7 +4,11 @@ getCityChaos() Netscript Function .. js:function:: getCityChaos(cityName) :RAM cost: 4 GB - :param string cityName: Name of city. Case-sensitive + :returns: Chaos in the specified city, or -1 if an invalid city was specified. - Returns the chaos in the specified city, or -1 if an invalid city was specified + Example: + + .. code-block:: javascript + + bladeburner.getCityChaos("Sector-12"); // returns: 3800.1 diff --git a/doc/source/netscript/bladeburnerapi/getCityEstimatedCommunities.rst b/doc/source/netscript/bladeburnerapi/getCityEstimatedCommunities.rst index 2dd20c9f2..34cace15f 100644 --- a/doc/source/netscript/bladeburnerapi/getCityEstimatedCommunities.rst +++ b/doc/source/netscript/bladeburnerapi/getCityEstimatedCommunities.rst @@ -4,8 +4,12 @@ getCityEstimatedCommunities() Netscript Function .. js:function:: getCityEstimatedCommunities(cityName) :RAM cost: 4 GB - :param string cityName: Name of city. Case-sensitive + :returns: Estimated number of Synthoid communities in the specified city, + or -1 if an invalid city was specified. - Returns the estimated number of Synthoid communities in the specified city, - or -1 if an invalid city was specified. + Example: + + .. code-block:: javascript + + bladeburner.getCityEstimatedCommunities("Sector-12"); // returns: 76 \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/getCityEstimatedPopulation.rst b/doc/source/netscript/bladeburnerapi/getCityEstimatedPopulation.rst index 328f2aa19..bca2c69ed 100644 --- a/doc/source/netscript/bladeburnerapi/getCityEstimatedPopulation.rst +++ b/doc/source/netscript/bladeburnerapi/getCityEstimatedPopulation.rst @@ -4,8 +4,12 @@ getCityEstimatedPopulation() Netscript Function .. js:function:: getCityEstimatedPopulation(cityName) :RAM cost: 4 GB - :param string cityName: Name of city. Case-sensitive + :returns: Estimated number of Synthoids in the specified city, or -1 if an + invalid city was specified. - Returns the estimated number of Synthoids in the specified city, or -1 - if an invalid city was specified. + Example: + + .. code-block:: javascript + + bladeburner.getCityEstimatedPopulation("Sector-12"); // returns: 1240000 \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/getContractNames.rst b/doc/source/netscript/bladeburnerapi/getContractNames.rst index f5aa79808..612d8e6a4 100644 --- a/doc/source/netscript/bladeburnerapi/getContractNames.rst +++ b/doc/source/netscript/bladeburnerapi/getContractNames.rst @@ -4,5 +4,10 @@ getContractNames() Netscript Function .. js:function:: getContractNames() :RAM cost: 0.4 GB + :returns: Array of strings containing the names of all Bladeburner contracts. - Returns an array of strings containing the names of all Bladeburner contracts + Example: + + .. code-block:: javascript + + bladeburner.getContractNames(); // returns: ["Tracking"] \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/getCurrentAction.rst b/doc/source/netscript/bladeburnerapi/getCurrentAction.rst index d15e7fed2..ef4821bbf 100644 --- a/doc/source/netscript/bladeburnerapi/getCurrentAction.rst +++ b/doc/source/netscript/bladeburnerapi/getCurrentAction.rst @@ -4,8 +4,9 @@ getCurrentAction() Netscript Function .. js:function:: getCurrentAction() :RAM cost: 1 GB + :returns: An object that represents the player's current Bladeburner action. - Returns an object that represents the player's current Bladeburner action:: + Result:: { type: Type of Action @@ -14,3 +15,11 @@ getCurrentAction() Netscript Function If the player is not performing an action, the function will return an object with the 'type' property set to "Idle". + + Example: + + .. code-block:: javascript + + action = bladeburner.getCurrentAction(); + print(action.type); // "Contracts" + print(action.name); // "Tracking" diff --git a/doc/source/netscript/bladeburnerapi/getGeneralActionNames.rst b/doc/source/netscript/bladeburnerapi/getGeneralActionNames.rst index efa335998..a853fbd38 100644 --- a/doc/source/netscript/bladeburnerapi/getGeneralActionNames.rst +++ b/doc/source/netscript/bladeburnerapi/getGeneralActionNames.rst @@ -4,5 +4,10 @@ getGeneralActionNames() Netscript Function .. js:function:: getGeneralActionNames() :RAM cost: 0.4 GB + :returns: Array of strings containing the names of all general Bladeburner actions. - Returns an array of strings containing the names of all general Bladeburner actions + Example: + + .. code-block:: javascript + + bladeburner.getGeneralActionNames(); // returns: ["Training"] diff --git a/doc/source/netscript/bladeburnerapi/getOperationNames.rst b/doc/source/netscript/bladeburnerapi/getOperationNames.rst index 0bce307a9..dbb4497be 100644 --- a/doc/source/netscript/bladeburnerapi/getOperationNames.rst +++ b/doc/source/netscript/bladeburnerapi/getOperationNames.rst @@ -4,5 +4,10 @@ getOperationNames() Netscript Function .. js:function:: getOperationNames() :RAM cost: 0.4 GB + :returns: Array of strings containing the names of all Bladeburner operations. - Returns an array of strings containing the names of all Bladeburner operations + Example: + + .. code-block:: javascript + + bladeburner.getOperationNames(); // returns: ["Investigation"] diff --git a/doc/source/netscript/bladeburnerapi/getRank.rst b/doc/source/netscript/bladeburnerapi/getRank.rst index dca51ff25..fec20883c 100644 --- a/doc/source/netscript/bladeburnerapi/getRank.rst +++ b/doc/source/netscript/bladeburnerapi/getRank.rst @@ -4,5 +4,10 @@ getRank() Netscript Function .. js:function:: getRank() :RAM cost: 4 GB + :returns: Player's Bladeburner Rank. - Returns the player's Bladeburner Rank + Example: + + .. code-block:: javascript + + bladeburner.getRank(); // returns: 87135 diff --git a/doc/source/netscript/bladeburnerapi/getSkillLevel.rst b/doc/source/netscript/bladeburnerapi/getSkillLevel.rst index 832e16fa0..0f116dae1 100644 --- a/doc/source/netscript/bladeburnerapi/getSkillLevel.rst +++ b/doc/source/netscript/bladeburnerapi/getSkillLevel.rst @@ -1,12 +1,14 @@ getSkillLevel() Netscript Function ================================== -.. js:function:: getSkillLevel(skillName="") +.. js:function:: getSkillLevel(skillName) :RAM cost: 4 GB + :param string skillName: Name of skill. Case-sensitive. + :returns: Level of specified skill, -1 for invalid skills. - :param string skillName: Name of skill. Case-sensitive and must be an exact match + Example: - This function returns your level in the specified skill. + .. code-block:: javascript - The function returns -1 if an invalid skill name is passed in + bladeburner.getSkillLevel("Overclock"); // returns: 90 \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/getSkillNames.rst b/doc/source/netscript/bladeburnerapi/getSkillNames.rst index fd5a8ded5..70a811fb6 100644 --- a/doc/source/netscript/bladeburnerapi/getSkillNames.rst +++ b/doc/source/netscript/bladeburnerapi/getSkillNames.rst @@ -4,5 +4,10 @@ getSkillNames() Netscript Function .. js:function:: getSkillNames() :RAM cost: 0.4 GB + :returns: Array of strings containing the names of all Bladeburner skills. - Returns an array of strings containing the names of all Bladeburner skills + Example: + + .. code-block:: javascript + + bladeburner.getSkillNames(); // returns: ["Overclock"] diff --git a/doc/source/netscript/bladeburnerapi/getSkillPoints.rst b/doc/source/netscript/bladeburnerapi/getSkillPoints.rst index a6aabbc02..7323cfb07 100644 --- a/doc/source/netscript/bladeburnerapi/getSkillPoints.rst +++ b/doc/source/netscript/bladeburnerapi/getSkillPoints.rst @@ -4,5 +4,10 @@ getSkillPoints() Netscript Function .. js:function:: getSkillPoints() :RAM cost: 4 GB + :returns: Amount of Bladeburner skill points you have. - Returns the number of Bladeburner skill points you have + Example: + + .. code-block:: javascript + + bladeburner.getSkillPoints(); // returns: 1630 \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/getSkillUpgradeCost.rst b/doc/source/netscript/bladeburnerapi/getSkillUpgradeCost.rst index 6f88df730..27c509615 100644 --- a/doc/source/netscript/bladeburnerapi/getSkillUpgradeCost.rst +++ b/doc/source/netscript/bladeburnerapi/getSkillUpgradeCost.rst @@ -1,13 +1,14 @@ getSkillUpgradeCost() Netscript Function ======================================== -.. js:function:: getSkillUpgradeCost(skillName="") +.. js:function:: getSkillUpgradeCost(skillName) :RAM cost: 4 GB - :param string skillName: Name of skill. Case-sensitive and must be an exact match + :returns: Amount of skill points needed to upgrade the specified skill. -1 for invalid skills. - This function returns the number of skill points needed to upgrade the - specified skill. + Example: - The function returns -1 if an invalid skill name is passed in. + .. code-block:: javascript + + bladeburner.getSkillUpgradeCost("Overclock"); // returns: 120 diff --git a/doc/source/netscript/bladeburnerapi/getStamina.rst b/doc/source/netscript/bladeburnerapi/getStamina.rst index 13b0ebfac..9fbc50ab1 100644 --- a/doc/source/netscript/bladeburnerapi/getStamina.rst +++ b/doc/source/netscript/bladeburnerapi/getStamina.rst @@ -4,14 +4,11 @@ getStamina() Netscript Function .. js:function:: getStamina() :RAM cost: 4 GB + :returns: Array with two elements [Current stamina, Max stamina] - Returns an array with two elements: + Example: - [Current stamina, Max stamina] + .. code-block:: javascript - Example usage:: - - function getStaminaPercentage() { - let res = bladeburner.getStamina(); - return res[0] / res[1]; - } + res = bladeburner.getStamina(); + percentage = res[0] / res[1]; diff --git a/doc/source/netscript/bladeburnerapi/getTeamSize.rst b/doc/source/netscript/bladeburnerapi/getTeamSize.rst index bdfaf9be7..f0052768d 100644 --- a/doc/source/netscript/bladeburnerapi/getTeamSize.rst +++ b/doc/source/netscript/bladeburnerapi/getTeamSize.rst @@ -4,12 +4,16 @@ getTeamSize() Netscript Function .. js:function:: getTeamSize(type, name) :RAM cost: 4 GB - :param string type: Type of action. See :ref:`bladeburner_action_types` :param string name: Name of action. Must be an exact match - - Returns the number of Bladeburner team members you have assigned to the - specified action. + :returns: Number of Bladeburner team members you have assigned to the + specified action. Setting a team is only applicable for Operations and BlackOps. This function will return 0 for other action types. + + Example: + + .. code-block:: javascript + + bladeburner.getTeamSize("Operations", "Investigation"); // returns: 7 \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/joinBladeburnerDivision.rst b/doc/source/netscript/bladeburnerapi/joinBladeburnerDivision.rst index 58f9cbe2e..5274c4e1f 100644 --- a/doc/source/netscript/bladeburnerapi/joinBladeburnerDivision.rst +++ b/doc/source/netscript/bladeburnerapi/joinBladeburnerDivision.rst @@ -4,10 +4,13 @@ joinBladeburnerDivision() Netscript Function .. js:function:: joinBladeburnerDivision() :RAM cost: 4 GB + :returns: ``true`` if you successfully join the Bladeburner division, or if you + are already a member. Attempts to join the Bladeburner division. - Returns true if you successfully join the Bladeburner division, or if you - are already a member. + Example: - Returns false otherwise + .. code-block:: javascript + + bladeburner.joinBladeburnerDivision(); // returns: true \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/joinBladeburnerFaction.rst b/doc/source/netscript/bladeburnerapi/joinBladeburnerFaction.rst index 8cb103c88..26c4f40cc 100644 --- a/doc/source/netscript/bladeburnerapi/joinBladeburnerFaction.rst +++ b/doc/source/netscript/bladeburnerapi/joinBladeburnerFaction.rst @@ -4,10 +4,13 @@ joinBladeburnerFaction() Netscript Function .. js:function:: joinBladeburnerFaction() :RAM cost: 4 GB + :returns: ``true`` if you successfully join the Bladeburner faction, or if + you are already a member. Attempts to join the Bladeburner faction. - Returns true if you successfully join the Bladeburner faction, or if - you are already a member. + Example: - Returns false otherwise. + .. code-block:: javascript + + bladeburner.joinBladeburnerFaction(); // returns: true \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/setActionAutolevel.rst b/doc/source/netscript/bladeburnerapi/setActionAutolevel.rst index ede833539..aa42d7af5 100644 --- a/doc/source/netscript/bladeburnerapi/setActionAutolevel.rst +++ b/doc/source/netscript/bladeburnerapi/setActionAutolevel.rst @@ -4,9 +4,14 @@ setActionAutolevel() Netscript Function .. js:function:: setActionAutolevel(type, name, autoLevel) :RAM cost: 4 GB - :param string type: Type of action. See :ref:`bladeburner_action_types` :param string name: Name of action. Must be an exact match :param boolean autoLevel: Whether or not to autolevel this action Enable/disable autoleveling for the specified action. + + Example: + + .. code-block:: javascript + + bladeburner.setActionAutolevel("Contracts", "Tracking", true); diff --git a/doc/source/netscript/bladeburnerapi/setActionLevel.rst b/doc/source/netscript/bladeburnerapi/setActionLevel.rst index 3b4b09366..23a274940 100644 --- a/doc/source/netscript/bladeburnerapi/setActionLevel.rst +++ b/doc/source/netscript/bladeburnerapi/setActionLevel.rst @@ -4,9 +4,14 @@ setActionLevel() Netscript Function .. js:function:: setActionLevel(type, name, level) :RAM cost: 4 GB - :param string type: Type of action. See :ref:`bladeburner_action_types` :param string name: Name of action. Must be an exact match :param level int: Level to set this action to Set the level for the specified action. + + Example: + + .. code-block:: javascript + + bladeburner.setActionLevel("Contracts", "Tracking", 10); diff --git a/doc/source/netscript/bladeburnerapi/setTeamSize.rst b/doc/source/netscript/bladeburnerapi/setTeamSize.rst index c13886473..630d71af0 100644 --- a/doc/source/netscript/bladeburnerapi/setTeamSize.rst +++ b/doc/source/netscript/bladeburnerapi/setTeamSize.rst @@ -4,11 +4,15 @@ setTeamSize() Netscript Function .. js:function:: setTeamSize(type, name, size) :RAM cost: 4 GB - :param string type: Type of action. See :ref:`bladeburner_action_types` :param string name: Name of action. Must be an exact match :param int size: Number of team members to set. Will be converted using Math.round() + :returns: Team size or -1 for invalid actions. Set the team size for the specified Bladeburner action. - Returns the team size that was set, or -1 if the function failed. + Example: + + .. code-block:: javascript + + bladeburner.setTeamSize("Operations", "Investigation", 7); \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/startAction.rst b/doc/source/netscript/bladeburnerapi/startAction.rst index 1c6040135..c2e7cfc7a 100644 --- a/doc/source/netscript/bladeburnerapi/startAction.rst +++ b/doc/source/netscript/bladeburnerapi/startAction.rst @@ -4,9 +4,14 @@ startAction() Netscript Function .. js:function:: startAction(type, name) :RAM cost: 4 GB - :param string type: Type of action. See :ref:`bladeburner_action_types` :param string name: Name of action. Must be an exact match + :returns: ``true`` if the action was started successfully. - Attempts to start the specified Bladeburner action. Returns true if the action - was started successfully, and false otherwise. + Attempts to start the specified Bladeburner action. + + Example: + + .. code-block:: javascript + + bladeburner.startAction("Contracts", "Tracking"); // returns: true \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/stopBladeburnerAction.rst b/doc/source/netscript/bladeburnerapi/stopBladeburnerAction.rst index db59dea95..abb86f97e 100644 --- a/doc/source/netscript/bladeburnerapi/stopBladeburnerAction.rst +++ b/doc/source/netscript/bladeburnerapi/stopBladeburnerAction.rst @@ -6,3 +6,9 @@ stopBladeburnerAction() Netscript Function :RAM cost: 2 GB Stops the current Bladeburner action + + Example: + + .. code-block:: javascript + + bladeburner.stopBladeburnerAction(); \ No newline at end of file diff --git a/doc/source/netscript/bladeburnerapi/switchCity.rst b/doc/source/netscript/bladeburnerapi/switchCity.rst index a696b5057..ead7399dc 100644 --- a/doc/source/netscript/bladeburnerapi/switchCity.rst +++ b/doc/source/netscript/bladeburnerapi/switchCity.rst @@ -4,9 +4,13 @@ switchCity() Netscript Function .. js:function:: switchCity(cityName) :RAM cost: 4 GB - :param string cityName: Name of city + :returns: ``true`` if successful. Attempts to switch to the specified city (for Bladeburner only). - Returns true if successful, and false otherwise + Example: + + .. code-block:: javascript + + bladeburner.switchCity("Sector-12"); // returns: true diff --git a/doc/source/netscript/bladeburnerapi/upgradeSkill.rst b/doc/source/netscript/bladeburnerapi/upgradeSkill.rst index 191e38429..b5ceb43eb 100644 --- a/doc/source/netscript/bladeburnerapi/upgradeSkill.rst +++ b/doc/source/netscript/bladeburnerapi/upgradeSkill.rst @@ -4,8 +4,13 @@ upgradeSkill() Netscript Function .. js:function:: upgradeSkill(skillName) :RAM cost: 4 GB - :param string skillName: Name of Skill to be upgraded. Case-sensitive and must be an exact match + :returns: ``true`` if the skill is successfully upgraded. - Attempts to upgrade the specified Bladeburner skill. Returns true if the - skill is successfully upgraded, and false otherwise + Attempts to upgrade the specified Bladeburner skill. + + Example: + + .. code-block:: javascript + + bladeburner.upgradeSkill("Overclock"); // returns: true \ No newline at end of file diff --git a/doc/source/netscript/codingcontractapi/attempt.rst b/doc/source/netscript/codingcontractapi/attempt.rst index cbfca63aa..a0d569aec 100644 --- a/doc/source/netscript/codingcontractapi/attempt.rst +++ b/doc/source/netscript/codingcontractapi/attempt.rst @@ -1,22 +1,27 @@ attempt() Netscript Function ============================ -.. js:function:: attempt(answer, fn[, hostname/ip=current ip, opts={}]) +.. js:function:: attempt(answer, filename[, hostname=current hostname[, opts={}]]) + :RAM cost: 10 GB :param answer: Solution for the contract - :param string fn: Filename of the contract - :param string hostname/ip: Hostname or IP of the server containing the contract. + :param string filename: Filename of the contract + :param string hostname: Hostname of the server containing the contract. Optional. Defaults to current server if not provided :param object opts: Optional parameters for configuring function behavior. Properties: * returnReward (*boolean*) If truthy, then the function will return a string that states the contract's reward when it is successfully solved. + :returns: ``true`` if the solution was correct. If the :code:`returnReward` + option is configured, then the function will instead return a + string. If the contract is successfully solved, the string will + contain a description of the contract's reward. Otherwise, it will + be an empty string. Attempts to solve the Coding Contract with the provided solution. - :returns: Boolean indicating whether the solution was correct. If the :code:`returnReward` - option is configured, then the function will instead return a string. If the - contract is successfully solved, the string will contain a description of the - contract's reward. Otherwise, it will be an empty string. + Example: - :RAM cost: 10 GB + .. code-block:: javascript + + codingcontract.attempt("myanswer!", "contract-123.cct", "home"); diff --git a/doc/source/netscript/codingcontractapi/getContractType.rst b/doc/source/netscript/codingcontractapi/getContractType.rst index a4e4bec64..401a981e6 100644 --- a/doc/source/netscript/codingcontractapi/getContractType.rst +++ b/doc/source/netscript/codingcontractapi/getContractType.rst @@ -1,15 +1,19 @@ getContractType() Netscript Function ==================================== -.. js:function:: getContractType(fn[, hostname/ip=current ip]) - - :param string fn: Filename of the contract - :param string hostname/ip: Hostname or IP of the server containing the contract. - Optional. Defaults to current server if not provided - - Returns a name describing the type of problem posed by the Coding Contract. - (e.g. Find Largest Prime Factor, Total Ways to Sum, etc.) - - :returns: A string with the contract's problem type +.. js:function:: getContractType(filename[, hostname=current hostname]) :RAM cost: 5 GB + :param string filename: Filename of the contract + :param string hostname: Hostname of the server containing the contract. + Optional. Defaults to current server if not provided + :returns: A string with the contract's problem type + + Describes the type of problem posed by the Coding Contract. + (e.g. Find Largest Prime Factor, Total Ways to Sum, etc.) + + Example: + + .. code-block:: javascript + + codingcontract.getContractType("contract-123.cct", "home"); diff --git a/doc/source/netscript/codingcontractapi/getData.rst b/doc/source/netscript/codingcontractapi/getData.rst index 0efe2d224..b330f56cd 100644 --- a/doc/source/netscript/codingcontractapi/getData.rst +++ b/doc/source/netscript/codingcontractapi/getData.rst @@ -1,14 +1,22 @@ getData() Netscript Function ============================ -.. js:function:: getData(fn[, hostname/ip=current ip]) +.. js:function:: getData(filename[, hostname=current hostname]) - :param string fn: Filename of the contract - :param string hostname/ip: Hostname or IP of the server containing the contract. - Optional. Defaults to current server if not provided + :param string filename: Filename of the contract + :param string hostname: Hostname of the server containing the contract. + Optional. Defaults to current server if not provided + :returns: The specified contract's data. Different data type depending on + contract type. Get the data associated with the specific Coding Contract. Note that this is not the same as the contract's description. This is just the data that the contract wants you to act on in order to solve - :returns: The specified contract's data + Example: + + .. code-block:: javascript + + data = codingcontract.getData("contract-123.cct", "home"); + answer = solve(data); + codingcontract.attempt(answer, "contract-123.cct", "home"); \ No newline at end of file diff --git a/doc/source/netscript/codingcontractapi/getDescription.rst b/doc/source/netscript/codingcontractapi/getDescription.rst index b5852eb7b..62fa67d88 100644 --- a/doc/source/netscript/codingcontractapi/getDescription.rst +++ b/doc/source/netscript/codingcontractapi/getDescription.rst @@ -1,14 +1,18 @@ getDescription() Netscript Function =================================== -.. js:function:: getDescription(fn[, hostname/ip=current ip]) - - :param string fn: Filename of the contract - :param string hostname/ip: Hostname or IP of the server containing the contract. - Optional. Defaults to current server if not provided - - Get the full text description for the problem posed by the Coding Contract - - :returns: A string with the contract's text description +.. js:function:: getDescription(filename[, hostname=current hostname]) :RAM cost: 5 GB + :param string filename: Filename of the contract + :param string hostname: Hostname of the server containing the contract. + Optional. Defaults to current server if not provided + :returns: A string with the contract's text description + + Get the full text description for the problem posed by the Coding Contract. + + Example: + + .. code-block:: javascript + + codingcontract.getDescription("contract-123.cct", "home"); \ No newline at end of file diff --git a/doc/source/netscript/codingcontractapi/getNumTriesRemaining.rst b/doc/source/netscript/codingcontractapi/getNumTriesRemaining.rst index 7451aa6ab..7e8f90207 100644 --- a/doc/source/netscript/codingcontractapi/getNumTriesRemaining.rst +++ b/doc/source/netscript/codingcontractapi/getNumTriesRemaining.rst @@ -1,15 +1,19 @@ getNumTriesRemaining() Netscript Function ========================================= -.. js:function:: getNumTriesRemaining(fn[, hostname/ip=current ip]) +.. js:function:: getNumTriesRemaining(filename[, hostname=current hostname]) - :param string fn: Filename of the contract - :param string hostname/ip: Hostname or IP of the server containing the contract. - Optional. Defaults to current server if not provided + :RAM cost: 2 GB + :param string filename: Filename of the contract + :param string hostname: Hostname of the server containing the contract. + Optional. Defaults to current server if not provided + :returns: Number indicating how many attempts are remaining Get the number of tries remaining on the contract before it self-destructs. - :returns: Number indicating how many attempts are remaining + Example: - :RAM cost: 2 GB + .. code-block:: javascript + + codingcontract.getNumTriesRemaining("contract-123.cct", "home"); // returns: 5 \ No newline at end of file diff --git a/doc/source/netscript/gangapi/ascendMember.rst b/doc/source/netscript/gangapi/ascendMember.rst index 268b7691e..d925c373c 100644 --- a/doc/source/netscript/gangapi/ascendMember.rst +++ b/doc/source/netscript/gangapi/ascendMember.rst @@ -4,11 +4,7 @@ ascendMember() Netscript Function .. js:function:: ascendMember(name) :RAM cost: 4 GB - :param string name: Name of member to ascend - - Ascend the specified Gang Member. - :returns: An object with info about the ascension results. The object has the following structure:: @@ -22,3 +18,5 @@ ascendMember() Netscript Function agi: Agility multiplier gained from ascending. Decimal form cha: Charisma multiplier gained from ascending. Decimal form } + + Ascend the specified Gang Member. \ No newline at end of file diff --git a/doc/source/netscript/gangapi/canRecruitMember.rst b/doc/source/netscript/gangapi/canRecruitMember.rst index 967b63808..a4026ef3f 100644 --- a/doc/source/netscript/gangapi/canRecruitMember.rst +++ b/doc/source/netscript/gangapi/canRecruitMember.rst @@ -4,5 +4,4 @@ canRecruitMember() Netscript Function .. js:function:: canRecruitMember() :RAM cost: 1 GB - - :returns: Boolean indicating whether a member can currently be recruited + :returns: ``true`` if a member can be recruited. \ No newline at end of file diff --git a/doc/source/netscript/gangapi/getBonusTime.rst b/doc/source/netscript/gangapi/getBonusTime.rst index dfaff16cc..772b19845 100644 --- a/doc/source/netscript/gangapi/getBonusTime.rst +++ b/doc/source/netscript/gangapi/getBonusTime.rst @@ -4,12 +4,10 @@ getBonusTime() Netscript Function .. js:function:: getBonusTime() :RAM cost: 0 GB - - Returns the amount of accumulated "bonus time" (seconds) for the Gang mechanic. + :returns: Bonus time for the Gang mechanic in seconds "Bonus time" is accumulated when the game is offline or if the game is inactive in the browser. "Bonus time" makes the game progress faster, up to 10x the normal speed. - :returns: Bonus time for the Gang mechanic in seconds diff --git a/doc/source/netscript/gangapi/getChanceToWinClash.rst b/doc/source/netscript/gangapi/getChanceToWinClash.rst index bf48b0aee..db3cae7b7 100644 --- a/doc/source/netscript/gangapi/getChanceToWinClash.rst +++ b/doc/source/netscript/gangapi/getChanceToWinClash.rst @@ -4,8 +4,6 @@ getChanceToWinClash() Netscript Function .. js:function:: getChanceToWinClash(gangName) :RAM cost: 4 GB - :param string gangName: Target gang - - Returns the chance you have to win a clash with the specified gang. The chance - is returned in decimal form, not percentage + :returns: Chance you have to win a clash with the specified gang. The chance + is returned in decimal form. diff --git a/doc/source/netscript/gangapi/getEquipmentCost.rst b/doc/source/netscript/gangapi/getEquipmentCost.rst index c061f51e8..24f0aa237 100644 --- a/doc/source/netscript/gangapi/getEquipmentCost.rst +++ b/doc/source/netscript/gangapi/getEquipmentCost.rst @@ -4,11 +4,9 @@ getEquipmentCost() Netscript Function .. js:function:: getEquipmentCost(equipName) :RAM cost: 2 GB - :param string equipName: Name of equipment + :returns: Cost to purchase the specified Equipment/Augmentation (number). + Infinity for invalid arguments. Get the amount of money it takes to purchase a piece of Equipment or an Augmentation. - If an invalid Equipment/Augmentation is specified, this function will return Infinity. - - :returns: Cost to purchase the specified Equipment/Augmentation (number). Infinity - for invalid arguments + If an invalid Equipment/Augmentation is specified, this function will return Infinity. \ No newline at end of file diff --git a/doc/source/netscript/gangapi/getEquipmentNames.rst b/doc/source/netscript/gangapi/getEquipmentNames.rst index 30568b9d6..9a1ff8e2b 100644 --- a/doc/source/netscript/gangapi/getEquipmentNames.rst +++ b/doc/source/netscript/gangapi/getEquipmentNames.rst @@ -4,8 +4,8 @@ getEquipmentNames() Netscript Function .. js:function:: getEquipmentNames() :RAM cost: 1 GB + :returns: Array of strings of the names of all Equpiment/Augmentations Get the name of all possible equipment/upgrades you can purchase for your Gang Members. This includes Augmentations. - :returns: Array of strings of the names of all Equpiment/Augmentations diff --git a/doc/source/netscript/gangapi/getEquipmentStats.rst b/doc/source/netscript/gangapi/getEquipmentStats.rst index c9f7d2a8e..1b2c55339 100644 --- a/doc/source/netscript/gangapi/getEquipmentStats.rst +++ b/doc/source/netscript/gangapi/getEquipmentStats.rst @@ -1,17 +1,15 @@ getEquipmentStats() Netscript Function -===================================== +====================================== .. js:function:: getEquipmentStats(equipName) :RAM cost: 2 GB - :param string equipName: Name of equipment - :returns: A dictionary containing the stats of the equipment. - Get the specified equipment stats. + Get the specified equipment stats.:: - { - "str":1.04, - "def":1.04 - } + { + "str":1.04, + "def":1.04 + } diff --git a/doc/source/netscript/gangapi/getEquipmentType.rst b/doc/source/netscript/gangapi/getEquipmentType.rst index 05d31b0df..bebd6bdb0 100644 --- a/doc/source/netscript/gangapi/getEquipmentType.rst +++ b/doc/source/netscript/gangapi/getEquipmentType.rst @@ -4,8 +4,8 @@ getEquipmentType() Netscript Function .. js:function:: getEquipmentType(equipName) :RAM cost: 2 GB - :param string equipName: Name of equipment + :returns: A string stating the type of the equipment Get the specified equipment type, which can be one of the following: @@ -14,5 +14,3 @@ getEquipmentType() Netscript Function * Vehicle * Rootkit * Augmentation - - :returns: A string stating the type of the equipment diff --git a/doc/source/netscript/gangapi/getGangInformation.rst b/doc/source/netscript/gangapi/getGangInformation.rst index 1b1135dd5..7cad54aad 100644 --- a/doc/source/netscript/gangapi/getGangInformation.rst +++ b/doc/source/netscript/gangapi/getGangInformation.rst @@ -4,9 +4,6 @@ getGangInformation() Netscript Function .. js:function:: getGangInformation() :RAM cost: 2 GB - - Get general information about the gang - :returns: An object with the gang information. The object has the following structure:: @@ -23,3 +20,5 @@ getGangInformation() Netscript Function wantedLevel: Gang's wanted level wantedLevelGainRate: Wanted level gained/lost per second (negative for losses) } + + Get general information about the gang \ No newline at end of file diff --git a/doc/source/netscript/gangapi/getMemberInformation.rst b/doc/source/netscript/gangapi/getMemberInformation.rst index 3a4d0eb57..4888a2bec 100644 --- a/doc/source/netscript/gangapi/getMemberInformation.rst +++ b/doc/source/netscript/gangapi/getMemberInformation.rst @@ -4,11 +4,7 @@ getMemberInformation() Netscript Function .. js:function:: getMemberInformation(name) :RAM cost: 2 GB - :param string name: Name of member - - Get stat and equipment-related information about a Gang Member - :returns: An object with the gang member information. The object has the following structure:: @@ -36,3 +32,5 @@ getMemberInformation() Netscript Function strengthAscensionMult: Strength multiplier from ascension. Decimal form task: Name of currently assigned task } + + Get stat and equipment-related information about a Gang Member \ No newline at end of file diff --git a/doc/source/netscript/gangapi/getMemberNames.rst b/doc/source/netscript/gangapi/getMemberNames.rst index cd762fc96..ff7ac8d6d 100644 --- a/doc/source/netscript/gangapi/getMemberNames.rst +++ b/doc/source/netscript/gangapi/getMemberNames.rst @@ -4,7 +4,6 @@ getMemberNames() Netscript Function .. js:function:: getMemberNames() :RAM cost: 1 GB - - Get the names of all Gang members - :returns: An array of the names of all Gang members as strings + + Get the names of all Gang members \ No newline at end of file diff --git a/doc/source/netscript/gangapi/getOtherGangInformation.rst b/doc/source/netscript/gangapi/getOtherGangInformation.rst index 653aaac50..55fb99605 100644 --- a/doc/source/netscript/gangapi/getOtherGangInformation.rst +++ b/doc/source/netscript/gangapi/getOtherGangInformation.rst @@ -4,9 +4,6 @@ getOtherGangInformation() Netscript Function .. js:function:: getOtherGangInformation() :RAM cost: 2 GB - - Get territory and power information about all gangs - :returns: An object with information about all gangs The object has the following structure:: @@ -26,3 +23,5 @@ getOtherGangInformation() Netscript Function }, ... (for all six gangs) } + + Get territory and power information about all gangs \ No newline at end of file diff --git a/doc/source/netscript/gangapi/getTaskNames.rst b/doc/source/netscript/gangapi/getTaskNames.rst index eaf0d4757..8749ea3e1 100644 --- a/doc/source/netscript/gangapi/getTaskNames.rst +++ b/doc/source/netscript/gangapi/getTaskNames.rst @@ -4,7 +4,6 @@ getTaskNames() Netscript Function .. js:function:: getTaskNames() :RAM cost: 1 GB - - Get the name of all valid tasks that Gang members can be assigned to - :returns: Array of strings of all task names + + Get the name of all valid tasks that Gang members can be assigned to \ No newline at end of file diff --git a/doc/source/netscript/gangapi/getTaskStats.rst b/doc/source/netscript/gangapi/getTaskStats.rst index 6b0b15d2f..14eb71704 100644 --- a/doc/source/netscript/gangapi/getTaskStats.rst +++ b/doc/source/netscript/gangapi/getTaskStats.rst @@ -4,32 +4,36 @@ getTaskStats() Netscript Function .. js:function:: getTaskStats(taskName) :RAM cost: 1 GB - :param string name: Name of the task. + :returns: Detailed stats of a task. - Get the stats of a gang member stats. This is typically used to evaluate - which action should be executed next. + Examples: - { - name: Terrorism, - desc: "Assign this gang member to commit acts of terrorism + .. code-block:: javascript - Greatly increases respect - Greatly increases wanted level - Scales heavily with territory", - isHacking: false, - isCombat: true, - baseRespect: 0.01, - baseWanted: 6, - baseMoney: 0, - hackWeight: 20, - strWeight: 20, - defWeight: 20, - dexWeight: 20, - agiWeight: 0, - chaWeight: 20, - difficulty: 36, - territory: { - money: 1, - respect: 2, - wanted: 2 + { + name: Terrorism, + desc: "Assign this gang member to commit acts of terrorism + + Greatly increases respect - Greatly increases wanted level - Scales heavily with territory", + isHacking: false, + isCombat: true, + baseRespect: 0.01, + baseWanted: 6, + baseMoney: 0, + hackWeight: 20, + strWeight: 20, + defWeight: 20, + dexWeight: 20, + agiWeight: 0, + chaWeight: 20, + difficulty: 36, + territory: { + money: 1, + respect: 2, + wanted: 2 + } } - } + + Get the stats of a gang task stats. This is typically used to evaluate + which action should be executed next. \ No newline at end of file diff --git a/doc/source/netscript/gangapi/purchaseEquipment.rst b/doc/source/netscript/gangapi/purchaseEquipment.rst index 53b2bbf64..cffec4fc6 100644 --- a/doc/source/netscript/gangapi/purchaseEquipment.rst +++ b/doc/source/netscript/gangapi/purchaseEquipment.rst @@ -4,11 +4,9 @@ purchaseEquipment() Netscript Function .. js:function:: purchaseEquipment(memberName, equipName) :RAM cost: 4 GB - :param string memberName: Name of Gang member to purchase the equipment for :param string equipName: Name of Equipment/Augmentation to purchase + :returns: ``true`` if the equipment was purchased. Attempt to purchase the specified Equipment/Augmentation for the specified Gang member. - - :returns: True if the equipment was successfully purchased. False otherwise diff --git a/doc/source/netscript/gangapi/recruitMember.rst b/doc/source/netscript/gangapi/recruitMember.rst index d757aa77e..eb144364d 100644 --- a/doc/source/netscript/gangapi/recruitMember.rst +++ b/doc/source/netscript/gangapi/recruitMember.rst @@ -4,8 +4,8 @@ recruitMember() Netscript Function .. js:function:: recruitMember(name) :RAM cost: 2 GB - :param string name: Name of member to recruit + :returns: True if the member was successfully recruited. False otherwise Attempt to recruit a new gang member. @@ -13,5 +13,3 @@ recruitMember() Netscript Function * Cannot currently recruit a new member * There already exists a member with the specified name - - :returns: True if the member was successfully recruited. False otherwise diff --git a/doc/source/netscript/gangapi/setMemberTask.rst b/doc/source/netscript/gangapi/setMemberTask.rst index 78d700650..541431640 100644 --- a/doc/source/netscript/gangapi/setMemberTask.rst +++ b/doc/source/netscript/gangapi/setMemberTask.rst @@ -4,11 +4,10 @@ setMemberTask() Netscript Function .. js:function:: setMemberTask(memberName, taskName) :RAM cost: 2 GB - :param string memberName: Name of Gang member to assign :param string taskName: Task to assign + :returns: True if the Gang Member was successfully assigned to the task. False otherwise Attempts to assign the specified Gang Member to the specified task. If an invalid task is specified, the Gang member will be set to idle ("Unassigned") - :returns: True if the Gang Member was successfully assigned to the task. False otherwise diff --git a/doc/source/netscript/gangapi/setTerritoryWarfare.rst b/doc/source/netscript/gangapi/setTerritoryWarfare.rst index e09e36b6a..573b06b85 100644 --- a/doc/source/netscript/gangapi/setTerritoryWarfare.rst +++ b/doc/source/netscript/gangapi/setTerritoryWarfare.rst @@ -4,7 +4,6 @@ setTerritoryWarfare() Netscript Function .. js:function:: setTerritoryWarfare(engage) :RAM cost: 2 GB - :param bool engage: Whether or not to engage in territory warfare Set whether or not the gang should engage in territory warfare diff --git a/doc/source/netscript/hacknetnodeapi/getCacheUpgradeCost.rst b/doc/source/netscript/hacknetnodeapi/getCacheUpgradeCost.rst index 05d4af3bb..aa6c3f6d8 100644 --- a/doc/source/netscript/hacknetnodeapi/getCacheUpgradeCost.rst +++ b/doc/source/netscript/hacknetnodeapi/getCacheUpgradeCost.rst @@ -6,14 +6,12 @@ getCacheUpgradeCost() Netscript Function .. js:function:: getCacheUpgradeCost(i, n) :RAM cost: 0 GB - - :param number i: Index/Identifier of Hacknet Node. :ref:`See here for details ` + :param number i: Index of Hacknet Node. :ref:`See here for details ` :param number n: Number of times to upgrade cache. Must be positive. Rounded to nearest integer - + :return: Cost of upgrading the cache level of the specified Hacknet Server by ``n``. + .. note:: This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node). - Returns the cost of upgrading the cache level of the specified Hacknet Server by *n*. - - If an invalid value for *n* is provided, then this function returns 0. If the - specified Hacknet Server is already at the max cache level, then Infinity is returned. + If an invalid value for ``n`` is provided, then this function returns ``0``. If the + specified Hacknet Server is already at the max cache level, then ``Infinity`` is returned. diff --git a/doc/source/netscript/hacknetnodeapi/getCoreUpgradeCost.rst b/doc/source/netscript/hacknetnodeapi/getCoreUpgradeCost.rst index 2fd84df14..09f0a5a82 100644 --- a/doc/source/netscript/hacknetnodeapi/getCoreUpgradeCost.rst +++ b/doc/source/netscript/hacknetnodeapi/getCoreUpgradeCost.rst @@ -4,11 +4,9 @@ getCoreUpgradeCost() Netscript Function .. js:function:: getCoreUpgradeCost(i, n) :RAM cost: 0 GB - - :param number i: Index/Identifier of Hacknet Node. :ref:`See here for details ` + :param number i: Index of Hacknet Node. :ref:`See here for details ` :param number n: Number of times to upgrade cores. Must be positive. Rounded to nearest integer + :returns: Cost of upgrading the number of cores of the specified Hacknet Node by ``n``. - Returns the cost of upgrading the number of cores of the specified Hacknet Node by *n*. - - If an invalid value for *n* is provided, then this function returns 0. If the - specified Hacknet Node is already at the max number of cores, then Infinity is returned. + If an invalid value for ``n`` is provided, then this function returns ``0``. If the + specified Hacknet Node is already at the max number of cores, then ``Infinity`` is returned. diff --git a/doc/source/netscript/hacknetnodeapi/getLevelUpgradeCost.rst b/doc/source/netscript/hacknetnodeapi/getLevelUpgradeCost.rst index 64d55d7d0..683be393a 100644 --- a/doc/source/netscript/hacknetnodeapi/getLevelUpgradeCost.rst +++ b/doc/source/netscript/hacknetnodeapi/getLevelUpgradeCost.rst @@ -4,11 +4,9 @@ getLevelUpgradeCost() Netscript Function .. js:function:: getLevelUpgradeCost(i, n) :RAM cost: 0 GB - - :param number i: Index/Identifier of Hacknet Node. :ref:`See here for details ` + :param number i: Index of Hacknet Node. :ref:`See here for details ` :param number n: Number of levels to upgrade. Must be positive. Rounded to nearest integer + :returns: Cost of upgrading the specified Hacknet Node by ``n`` levels. - Returns the cost of upgrading the specified Hacknet Node by *n* levels. - - If an invalid value for *n* is provided, then this function returns 0. If the - specified Hacknet Node is already at max level, then Infinity is returned. + If an invalid value for ``n`` is provided, then this function returns ``0``. If the + specified Hacknet Node is already at max level, then ``Infinity`` is returned. diff --git a/doc/source/netscript/hacknetnodeapi/getNodeStats.rst b/doc/source/netscript/hacknetnodeapi/getNodeStats.rst index c19a67a98..73da1ed06 100644 --- a/doc/source/netscript/hacknetnodeapi/getNodeStats.rst +++ b/doc/source/netscript/hacknetnodeapi/getNodeStats.rst @@ -6,10 +6,10 @@ getNodeStats() Netscript Function .. js:function:: getNodeStats(i) :RAM cost: 0 GB + :param number i: Index of Hacknet Node. :ref:`See here for details ` + :returns: Object containing a variety of stats about the specified Hacknet Node - :param number i: Index/Identifier of Hacknet Node. :ref:`See here for details ` - - Returns an object containing a variety of stats about the specified Hacknet Node:: + :: { name: Node's name ("hacknet-node-5"), @@ -24,5 +24,5 @@ getNodeStats() Netscript Function } .. note:: Note that for Hacknet Nodes, production refers to the amount of money the node generates. - For Hacknet Servers (the upgraded version of Hacknet Nodes), production refers to the amount - of hashes the node generates. + For Hacknet Servers (the upgraded version of Hacknet Nodes), production refers to the amount + of hashes the node generates. diff --git a/doc/source/netscript/hacknetnodeapi/getPurchaseNodeCost.rst b/doc/source/netscript/hacknetnodeapi/getPurchaseNodeCost.rst index 9990a3a07..0dd53c7a7 100644 --- a/doc/source/netscript/hacknetnodeapi/getPurchaseNodeCost.rst +++ b/doc/source/netscript/hacknetnodeapi/getPurchaseNodeCost.rst @@ -4,5 +4,4 @@ getPurchaseNodeCost() Netscript Function .. js:function:: getPurchaseNodeCost() :RAM cost: 0 GB - - Returns the cost of purchasing a new Hacknet Node + :returns: Cost of purchasing a new Hacknet Node. diff --git a/doc/source/netscript/hacknetnodeapi/getRamUpgradeCost.rst b/doc/source/netscript/hacknetnodeapi/getRamUpgradeCost.rst index 9aedf44a3..1db422fb6 100644 --- a/doc/source/netscript/hacknetnodeapi/getRamUpgradeCost.rst +++ b/doc/source/netscript/hacknetnodeapi/getRamUpgradeCost.rst @@ -4,11 +4,9 @@ getRamUpgradeCost() Netscript Function .. js:function:: getRamUpgradeCost(i, n) :RAM cost: 0 GB + :param number i: Index of Hacknet Node. :ref:`See here for details ` + :param number n: Number of times to upgrade RAM. Must be positive. Rounded to nearest integer. + :returns: Cost of upgrading the RAM of the specified Hacknet Node ``n`` times. - :param number i: Index/Identifier of Hacknet Node. :ref:`See here for details ` - :param number n: Number of times to upgrade RAM. Must be positive. Rounded to nearest integer - - Returns the cost of upgrading the RAM of the specified Hacknet Node *n* times. - - If an invalid value for *n* is provided, then this function returns 0. If the - specified Hacknet Node is already at max RAM, then Infinity is returned. + If an invalid value for ``n`` is provided, then this function returns ``0``. If the + specified Hacknet Node is already at max RAM, then ``Infinity`` is returned. diff --git a/doc/source/netscript/hacknetnodeapi/hashCost.rst b/doc/source/netscript/hacknetnodeapi/hashCost.rst index 2a57cc377..fc5f7b5d4 100644 --- a/doc/source/netscript/hacknetnodeapi/hashCost.rst +++ b/doc/source/netscript/hacknetnodeapi/hashCost.rst @@ -6,20 +6,18 @@ hashCost() Netscript Function .. js:function:: hashCost(upgName) :RAM cost: 0 GB - :param string upgName: Name of upgrade to get the cost of. Must be an exact match + :returns: Number of hashes required for the specified upgrade. The name of + the upgrade must be an exact match. .. note:: 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: .. code:: javascript - var upgradeName = "Sell for Corporation Funds"; + upgradeName = "Sell for Corporation Funds"; if (hacknet.numHashes() > hacknet.hashCost(upgradeName)) { hacknet.spendHashes(upgName); } diff --git a/doc/source/netscript/hacknetnodeapi/maxNumNodes.rst b/doc/source/netscript/hacknetnodeapi/maxNumNodes.rst index 0007a5036..c39d43110 100644 --- a/doc/source/netscript/hacknetnodeapi/maxNumNodes.rst +++ b/doc/source/netscript/hacknetnodeapi/maxNumNodes.rst @@ -1,8 +1,7 @@ maxNumNodes() Netscript Function -============================= +================================ .. js:function:: maxNumNodes() :RAM cost: 0 GB - - Returns the maximum number of Hacknet Nodes you can own. + :returns: Maximum number of Hacknet Nodes you can own. diff --git a/doc/source/netscript/hacknetnodeapi/numHashes.rst b/doc/source/netscript/hacknetnodeapi/numHashes.rst index 825e554b5..62d54289a 100644 --- a/doc/source/netscript/hacknetnodeapi/numHashes.rst +++ b/doc/source/netscript/hacknetnodeapi/numHashes.rst @@ -6,8 +6,8 @@ numHashes() Netscript Function .. js:function:: numHashes() :RAM cost: 0 GB + :returns: Number of hashes you have. .. note:: This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node). - Returns the number of hashes you have diff --git a/doc/source/netscript/hacknetnodeapi/numNodes.rst b/doc/source/netscript/hacknetnodeapi/numNodes.rst index b50977ded..ef53758d1 100644 --- a/doc/source/netscript/hacknetnodeapi/numNodes.rst +++ b/doc/source/netscript/hacknetnodeapi/numNodes.rst @@ -4,5 +4,4 @@ numNodes() Netscript Function .. js:function:: numNodes() :RAM cost: 0 GB - - Returns the number of Hacknet Nodes you own. + :returns: Number of Hacknet Nodes you own. diff --git a/doc/source/netscript/hacknetnodeapi/purchaseNode.rst b/doc/source/netscript/hacknetnodeapi/purchaseNode.rst index 4310aac70..2d198d940 100644 --- a/doc/source/netscript/hacknetnodeapi/purchaseNode.rst +++ b/doc/source/netscript/hacknetnodeapi/purchaseNode.rst @@ -4,10 +4,8 @@ purchaseNode() Netscript Function .. js:function:: purchaseNode() :RAM cost: 0 GB + :returns: Index of the newly purchased node. -1 on failure. - Purchases a new Hacknet Node. Returns a number with the index of the Hacknet Node. + Purchases a new Hacknet Node. This index is equivalent to the number at the end of the Hacknet Node's name (e.g The Hacknet Node named 'hacknet-node-4' will have an index of 4). - - If the player cannot afford to purchase a new Hacknet Node then the function - will return -1. diff --git a/doc/source/netscript/hacknetnodeapi/spendHashes.rst b/doc/source/netscript/hacknetnodeapi/spendHashes.rst index 3eadfddfe..b622b5044 100644 --- a/doc/source/netscript/hacknetnodeapi/spendHashes.rst +++ b/doc/source/netscript/hacknetnodeapi/spendHashes.rst @@ -6,19 +6,19 @@ spendHashes() Netscript Function .. js:function:: spendHashes(upgName, upgTarget) :RAM cost: 0 GB - :param string upgName: Name of upgrade to spend hashes on. Must be an exact match :param string upgTarget: Object to which upgrade applies. Required for certain upgrades + :returns: ``true`` if the purchase was successful. .. note:: This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node). - Spend the hashes generated by your Hacknet Servers on an upgrade. Returns a boolean value - - true if the upgrade is successfully purchased, and false otherwise. + Spend the hashes generated by your Hacknet Servers on an upgrade. - The name of the upgrade must be an exact match. The :code:`upgTarget` argument is used - for upgrades such as :code:`Reduce Minimum Security`, which applies to a specific server. - In this case, the :code:`upgTarget` argument must be the hostname of the server. + The name of the upgrade must be an exact match. The ``upgTarget`` argument + is used for upgrades such as ``Reduce Minimum Security``, which applies to a + specific server. In this case, the ``upgTarget`` argument must be the + hostname of the server. Example: diff --git a/doc/source/netscript/hacknetnodeapi/upgradeCache.rst b/doc/source/netscript/hacknetnodeapi/upgradeCache.rst index bee20f638..f670975ea 100644 --- a/doc/source/netscript/hacknetnodeapi/upgradeCache.rst +++ b/doc/source/netscript/hacknetnodeapi/upgradeCache.rst @@ -6,16 +6,11 @@ upgradeCache() Netscript Function .. js:function:: upgradeCache(i, n) :RAM cost: 0 GB - - :param number i: Index/Identifier of Hacknet Node. :ref:`See here for details ` + :param number i: Index of Hacknet Node. :ref:`See here for details ` :param number n: Number of cache levels to purchase. Must be positive. Rounded to nearest integer + :returns: ``true`` if the upgrade was successful. .. note:: This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node). - Tries to upgrade the specified Hacknet Server's cache *n* times. - - Returns true if it successfully upgrades the Server's cache *n* times, or if - it purchases some positive amount and the Server reaches its max cache level. - - Returns false otherwise. + Tries to upgrade the specified Hacknet Server's cache ``n`` times. diff --git a/doc/source/netscript/hacknetnodeapi/upgradeCore.rst b/doc/source/netscript/hacknetnodeapi/upgradeCore.rst index 19d51b6d2..797fca393 100644 --- a/doc/source/netscript/hacknetnodeapi/upgradeCore.rst +++ b/doc/source/netscript/hacknetnodeapi/upgradeCore.rst @@ -4,13 +4,8 @@ upgradeCore() Netscript Function .. js:function:: upgradeCore(i, n) :RAM cost: 0 GB - - :param number i: Index/Identifier of Hacknet Node. :ref:`See here for details ` + :param number i: Index of Hacknet Node. :ref:`See here for details ` :param number n: Number of cores to purchase. Must be positive. Rounded to nearest integer + :returns: ``true`` if the upgrade was successful. - Tries to purchase *n* cores for the specified Hacknet Node. - - Returns true if it successfully purchases *n* cores for the Hacknet Node or if - it purchases some positive amount and the Node reaches its max number of cores. - - Returns false otherwise. + Tries to purchase ``n`` cores for the specified Hacknet Node. diff --git a/doc/source/netscript/hacknetnodeapi/upgradeLevel.rst b/doc/source/netscript/hacknetnodeapi/upgradeLevel.rst index be1bff81b..498834c32 100644 --- a/doc/source/netscript/hacknetnodeapi/upgradeLevel.rst +++ b/doc/source/netscript/hacknetnodeapi/upgradeLevel.rst @@ -4,13 +4,8 @@ upgradeLevel() Netscript Function .. js:function:: upgradeLevel(i, n) :RAM cost: 0 GB - - :param number i: Index/Identifier of Hacknet Node. :ref:`See here for details ` + :param number i: Index of Hacknet Node. :ref:`See here for details ` :param number n: Number of levels to purchase. Must be positive. Rounded to nearest integer + :returns: ``true`` if the upgrade was successful. Tries to upgrade the level of the specified Hacknet Node by *n*. - - Returns true if the Hacknet Node's level is successfully upgraded by *n* or - if it is upgraded by some positive amount and the Node reaches its max level. - - Returns false otherwise. diff --git a/doc/source/netscript/hacknetnodeapi/upgradeRam.rst b/doc/source/netscript/hacknetnodeapi/upgradeRam.rst index 21d5d748d..9d2c7b569 100644 --- a/doc/source/netscript/hacknetnodeapi/upgradeRam.rst +++ b/doc/source/netscript/hacknetnodeapi/upgradeRam.rst @@ -4,15 +4,10 @@ upgradeRam() Netscript Function .. js:function:: upgradeRam(i, n) :RAM cost: 0 GB + :param number i: Index of Hacknet Node. :ref:`See here for details ` + :param number n: Number of times to upgrade RAM. Must be positive. Rounded to nearest integer. + :returns: ``true`` if the upgrade was successful. - :param number i: Index/Identifier of Hacknet Node. :ref:`See here for details ` - :param number n: Number of times to upgrade RAM. Must be positive. Rounded to nearest integer - - Tries to upgrade the specified Hacknet Node's RAM *n* times. Note that each upgrade - doubles the Node's RAM. So this is equivalent to multiplying the Node's RAM by - 2 :sup:`n`. - - Returns true if the Hacknet Node's RAM is successfully upgraded *n* times or if - it is upgraded some positive number of times and the Node reaches it max RAM. - - Returns false otherwise. + Tries to upgrade the specified Hacknet Node's RAM ``n`` times. Note that + each upgrade doubles the Node's RAM. So this is equivalent to multiplying + the Node's RAM by 2 :sup:`n`. diff --git a/doc/source/netscript/netscriptgangapi.rst b/doc/source/netscript/netscriptgangapi.rst index d75715e72..24cedd801 100644 --- a/doc/source/netscript/netscriptgangapi.rst +++ b/doc/source/netscript/netscriptgangapi.rst @@ -33,9 +33,11 @@ In :ref:`netscriptjs`:: recruitMember() getTaskNames() setMemberTask() + getTaskStats() getEquipmentNames() getEquipmentCost() getEquipmentType() + getEquipmentStats() purchaseEquipment() ascendMember() setTerritoryWarfare() diff --git a/doc/source/netscript/netscripthacknetnodeapi.rst b/doc/source/netscript/netscripthacknetnodeapi.rst index 0cd7dd897..706cf6495 100644 --- a/doc/source/netscript/netscripthacknetnodeapi.rst +++ b/doc/source/netscript/netscripthacknetnodeapi.rst @@ -29,6 +29,7 @@ In :ref:`netscriptjs`:: :caption: API Functions: numNodes() + maxNumNodes() purchaseNode() getPurchaseNodeCost() getNodeStats() diff --git a/doc/source/netscript/netscriptsingularityfunctions.rst b/doc/source/netscript/netscriptsingularityfunctions.rst index b9ed4ea56..44b311269 100644 --- a/doc/source/netscript/netscriptsingularityfunctions.rst +++ b/doc/source/netscript/netscriptsingularityfunctions.rst @@ -45,10 +45,13 @@ level 3, then you will be able to access all of the Singularity Functions. createProgram() commitCrime() getCrimeChance() + getCrimeStats() getOwnedAugmentations() getOwnedSourceFiles() getAugmentationsFromFaction() getAugmentationPrereq() getAugmentationCost() + getAugmentationStats() purchaseAugmentation() installAugmentations() + softReset() diff --git a/doc/source/netscript/singularityfunctions/applyToCompany.rst b/doc/source/netscript/singularityfunctions/applyToCompany.rst index 7f16e2b0e..c8aee245e 100644 --- a/doc/source/netscript/singularityfunctions/applyToCompany.rst +++ b/doc/source/netscript/singularityfunctions/applyToCompany.rst @@ -4,7 +4,6 @@ applyToCompany() Netscript Function .. js:function:: applyToCompany(companyName, field) :RAM cost: 3 GB - :param string companyName: Name of company to apply to. CASE-SENSITIVE. :param string field: Field to which you want to apply. Not case-sensitive @@ -22,12 +21,10 @@ applyToCompany() Netscript Function * part-time employee * waiter * part-time waiter + :returns: ``true`` if you got the job. If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function. This function will automatically try to apply to the specified company for a position in the specified field. This function can also be used to apply for promotions by specifying the company and field you - are already employed at. - - This function will return true if you successfully get a job/promotion, and false otherwise. Note that - if you are trying to use this function to apply for a promotion and you don't get one, it will return false. + are already employed at. \ No newline at end of file diff --git a/doc/source/netscript/singularityfunctions/checkFactionInvitations.rst b/doc/source/netscript/singularityfunctions/checkFactionInvitations.rst index 472e35f0e..4edd9c53a 100644 --- a/doc/source/netscript/singularityfunctions/checkFactionInvitations.rst +++ b/doc/source/netscript/singularityfunctions/checkFactionInvitations.rst @@ -4,7 +4,7 @@ checkFactionInvitations() Netscript Function .. js:function:: checkFactionInvitations() :RAM cost: 3 GB + :returns: Array with the name of all Factions with whom you have oustanding invitations. If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function. - Returns an array with the name of all Factions you currently have oustanding invitations from. diff --git a/doc/source/netscript/singularityfunctions/commitCrime.rst b/doc/source/netscript/singularityfunctions/commitCrime.rst index 4c09f0391..0f8aab6ad 100644 --- a/doc/source/netscript/singularityfunctions/commitCrime.rst +++ b/doc/source/netscript/singularityfunctions/commitCrime.rst @@ -4,7 +4,6 @@ commitCrime() Netscript Function .. js:function:: commitCrime(crime) :RAM cost: 5 GB - :param string crime: Name of crime to attempt. Not case-sensitive. This argument is fairly lenient in terms of what inputs it accepts. Here is a list of valid inputs for all of the crimes: @@ -28,9 +27,9 @@ commitCrime() Netscript Function (such as working for a company or training at a gym), then running this function will automatically cancel that action and give you your earnings. This function returns the number of seconds it takes to attempt the specified crime (e.g It takes 60 seconds to attempt the 'Rob Store' crime, - so running *commitCrime('rob store')* will return 60). + so running ``commitCrime('rob store')`` will return 60). Warning: I do not recommend using the time returned from this function to try and schedule your crime attempts. - Instead, I would use the isBusy() Singularity function to check whether you have finished attempting a crime. + Instead, I would use the :doc:`isBusy` Singularity function to check whether you have finished attempting a crime. This is because although the game sets a certain crime to be X amount of seconds, there is no guarantee that your browser will follow that time limit. diff --git a/doc/source/netscript/singularityfunctions/createProgram.rst b/doc/source/netscript/singularityfunctions/createProgram.rst index 2165e75c9..7bfa657f7 100644 --- a/doc/source/netscript/singularityfunctions/createProgram.rst +++ b/doc/source/netscript/singularityfunctions/createProgram.rst @@ -4,8 +4,8 @@ createProgram() Netscript Function .. js:function:: createProgram(programName) :RAM cost: 5 GB - :param string programName: Name of program to create. Not case-sensitive + :returns: ``true`` if you successfully start working on the specified program. If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function. @@ -28,5 +28,3 @@ createProgram() Netscript Function * DeepscanV2.exe: 400 * ServerProfiler.exe: 75 * AutoLink.exe: 25 - - This function returns true if you successfully start working on the specified program, and false otherwise. diff --git a/doc/source/netscript/singularityfunctions/donateToFaction.rst b/doc/source/netscript/singularityfunctions/donateToFaction.rst index f614d1536..ef0da9ce1 100644 --- a/doc/source/netscript/singularityfunctions/donateToFaction.rst +++ b/doc/source/netscript/singularityfunctions/donateToFaction.rst @@ -4,11 +4,10 @@ donateToFaction() Netscript Function .. js:function:: donateToFaction(factionName, donateAmt) :RAM cost: 5 GB - :param string factionName: Name of faction to donate to. CASE-SENSITIVE :param number donateAmt: Amount of money to donate + :returns: ``true`` if you successfully donate the money. If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function. - Attempts to donate money to the specified faction in exchange for reputation. - Returns true if you successfully donate the money, and false otherwise. + Attempts to donate money to the specified faction in exchange for reputation. \ No newline at end of file diff --git a/doc/source/netscript/singularityfunctions/getAugmentationCost.rst b/doc/source/netscript/singularityfunctions/getAugmentationCost.rst index f09618ed8..01a5735a2 100644 --- a/doc/source/netscript/singularityfunctions/getAugmentationCost.rst +++ b/doc/source/netscript/singularityfunctions/getAugmentationCost.rst @@ -4,12 +4,11 @@ getAugmentationCost() Netscript Function .. js:function:: getAugmentationCost(augName) :RAM cost: 5 GB - - :param string augName: Name of Augmentation. CASE-SENSITIVE + :param string augName: Name of Augmentation. case-sensitive. If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function. This function returns an array with two elements that gives the cost for the specified Augmentation. The first element in the returned array is the reputation requirement of the Augmentation, and the second element is the money cost. - If an invalid Augmentation name is passed in for the *augName* argument, this function will return the array [-1, -1]. + If an invalid Augmentation name is passed in for the ``augName`` argument, this function will return the array [-1, -1]. diff --git a/doc/source/netscript/tixapi/buyStock.rst b/doc/source/netscript/tixapi/buyStock.rst index 06e70c891..576b096c2 100644 --- a/doc/source/netscript/tixapi/buyStock.rst +++ b/doc/source/netscript/tixapi/buyStock.rst @@ -3,9 +3,10 @@ buyStock() Netscript Function .. js:function:: buyStock(sym, shares) + :RAM cost: 2.5 GB :param string sym: Symbol of stock to purchase :param number shares: Number of shares to purchased. Must be positive. Will be rounded to nearest integer - :RAM cost: 2.5 GB + Attempts to purchase shares of a stock using a `Market Order `_. diff --git a/doc/source/netscript/tixapi/cancelOrder.rst b/doc/source/netscript/tixapi/cancelOrder.rst index da9cb18c0..2271fb7c7 100644 --- a/doc/source/netscript/tixapi/cancelOrder.rst +++ b/doc/source/netscript/tixapi/cancelOrder.rst @@ -3,6 +3,7 @@ cancelOrder() Netscript Function .. js:function:: cancelOrder(sym, shares, price, type, pos) + :RAM cost: 2.5 GB :param string sym: Symbol of stock to player order for :param number shares: Number of shares for order. Must be positive. Will be rounded to nearest integer :param number price: Execution price for the order @@ -17,7 +18,6 @@ cancelOrder() Netscript Function :param string pos: Specifies whether the order is a "Long" or "Short" position. The Values "L" or "S" can also be used. This is NOT case-sensitive. - :RAM cost: 2.5 GB Cancels an oustanding Limit or Stop order on the stock market. diff --git a/doc/source/netscript/tixapi/getStockAskPrice.rst b/doc/source/netscript/tixapi/getStockAskPrice.rst index 8365df502..0d1add629 100644 --- a/doc/source/netscript/tixapi/getStockAskPrice.rst +++ b/doc/source/netscript/tixapi/getStockAskPrice.rst @@ -3,8 +3,9 @@ getStockAskPrice() Netscript Function .. js:function:: getStockAskPrice(sym) - :param string sym: Stock symbol :RAM cost: 2 GB + :param string sym: Stock symbol + Given a stock's symbol, returns the ask price of that stock (the symbol is a sequence of two to four capital letters, **not** the name of the company to which that stock belongs). diff --git a/doc/source/netscript/tixapi/getStockBidPrice.rst b/doc/source/netscript/tixapi/getStockBidPrice.rst index e9e03e950..07e633c45 100644 --- a/doc/source/netscript/tixapi/getStockBidPrice.rst +++ b/doc/source/netscript/tixapi/getStockBidPrice.rst @@ -3,8 +3,9 @@ getStockBidPrice() Netscript Function .. js:function:: getStockBidPrice(sym) - :param string sym: Stock symbol :RAM cost: 2 GB + :param string sym: Stock symbol + Given a stock's symbol, returns the bid price of that stock (the symbol is a sequence of two to four capital letters, **not** the name of the company to which that stock belongs). diff --git a/doc/source/netscript/tixapi/getStockForecast.rst b/doc/source/netscript/tixapi/getStockForecast.rst index 7ce63f319..34886bc47 100644 --- a/doc/source/netscript/tixapi/getStockForecast.rst +++ b/doc/source/netscript/tixapi/getStockForecast.rst @@ -3,8 +3,9 @@ getStockForecast() Netscript Function .. js:function:: getStockForecast(sym) - :param string sym: Symbol of stock :RAM cost: 2.5 GB + :param string sym: Symbol of stock + Returns the probability that the specified stock's price will increase (as opposed to decrease) during the next tick. diff --git a/doc/source/netscript/tixapi/getStockMaxShares.rst b/doc/source/netscript/tixapi/getStockMaxShares.rst index 4c1838183..b654618b0 100644 --- a/doc/source/netscript/tixapi/getStockMaxShares.rst +++ b/doc/source/netscript/tixapi/getStockMaxShares.rst @@ -3,8 +3,9 @@ getStockMaxShares() Netscript Function .. js:function:: getStockMaxShares(sym) - :param string sym: Stock symbol :RAM cost: 2 GB + :param string sym: Stock symbol + Returns the maximum number of shares that the stock has. This is the maximum amount of the stock that can be purchased in both the Long and Short diff --git a/doc/source/netscript/tixapi/getStockPosition.rst b/doc/source/netscript/tixapi/getStockPosition.rst index 048a3bfb3..16a30a1bb 100644 --- a/doc/source/netscript/tixapi/getStockPosition.rst +++ b/doc/source/netscript/tixapi/getStockPosition.rst @@ -3,8 +3,9 @@ getStockPosition() Netscript Function .. js:function:: getStockPosition(sym) - :param string sym: Stock symbol :RAM cost: 2 GB + :param string sym: Stock symbol + Returns an array of four elements that represents the player's position in a stock. diff --git a/doc/source/netscript/tixapi/getStockPrice.rst b/doc/source/netscript/tixapi/getStockPrice.rst index 623e0ce5e..413444aac 100644 --- a/doc/source/netscript/tixapi/getStockPrice.rst +++ b/doc/source/netscript/tixapi/getStockPrice.rst @@ -3,8 +3,9 @@ getStockPrice() Netscript Function .. js:function:: getStockPrice(sym) - :param string sym: Stock symbol :RAM cost: 2 GB + :param string sym: Stock symbol + Given a stock's symbol, returns the price of that stock (the symbol is a sequence of two to four capital letters, **not** the name of the company to which that stock belongs). diff --git a/doc/source/netscript/tixapi/getStockPurchaseCost.rst b/doc/source/netscript/tixapi/getStockPurchaseCost.rst index a686d1bca..9a0acc09e 100644 --- a/doc/source/netscript/tixapi/getStockPurchaseCost.rst +++ b/doc/source/netscript/tixapi/getStockPurchaseCost.rst @@ -1,13 +1,14 @@ getStockPurchaseCost() Netscript Function ========================================= - .. js:function:: getStockPurchaseCost(sym, shares, posType) +.. js:function:: getStockPurchaseCost(sym, shares, posType) + :RAM cost: 2 GB :param string sym: Stock symbol :param number shares: Number of shares to purchase :param string posType: Specifies whether the order is a "Long" or "Short" position. The values "L" or "S" can also be used. - :RAM cost: 2 GB + Calculates and returns how much it would cost to buy a given number of shares of a stock. This takes into account :ref:`spread ` diff --git a/doc/source/netscript/tixapi/getStockSaleGain.rst b/doc/source/netscript/tixapi/getStockSaleGain.rst index 2dcbf8b78..9bcf0f2ae 100644 --- a/doc/source/netscript/tixapi/getStockSaleGain.rst +++ b/doc/source/netscript/tixapi/getStockSaleGain.rst @@ -1,13 +1,14 @@ getStockSaleGain() Netscript Function ===================================== - .. js:function:: getStockSaleGain(sym, shares, posType) +.. js:function:: getStockSaleGain(sym, shares, posType) + :RAM cost: 2 GB :param string sym: Stock symbol :param number shares: Number of shares to sell :param string posType: Specifies whether the order is a "Long" or "Short" position. The values "L" or "S" can also be used. - :RAM cost: 2 GB + Calculates and returns how much you would gain from selling a given number of shares of a stock. This takes into account :ref:`spread ` diff --git a/doc/source/netscript/tixapi/getStockVolatility.rst b/doc/source/netscript/tixapi/getStockVolatility.rst index 0cc5fccb6..b15602126 100644 --- a/doc/source/netscript/tixapi/getStockVolatility.rst +++ b/doc/source/netscript/tixapi/getStockVolatility.rst @@ -3,8 +3,9 @@ getStockVolatility() Netscript Function .. js:function:: getStockVolatility(sym) - :param string sym: Symbol of stock :RAM cost: 2.5 GB + :param string sym: Symbol of stock + Returns the volatility of the specified stock. diff --git a/doc/source/netscript/tixapi/placeOrder.rst b/doc/source/netscript/tixapi/placeOrder.rst index 7edaab223..7bcda6cfe 100644 --- a/doc/source/netscript/tixapi/placeOrder.rst +++ b/doc/source/netscript/tixapi/placeOrder.rst @@ -3,6 +3,7 @@ placeOrder() Netscript Function .. js:function:: placeOrder(sym, shares, price, type, pos) + :RAM cost: 2.5 GB :param string sym: Symbol of stock to player order for :param number shares: Number of shares for order. Must be positive. Will be rounded to nearest integer :param number price: Execution price for the order @@ -17,7 +18,6 @@ placeOrder() Netscript Function :param string pos: Specifies whether the order is a "Long" or "Short" position. The Values "L" or "S" can also be used. This is NOT case-sensitive. - :RAM cost: 2.5 GB Places an order on the stock market. This function only works for :ref:`Limit and Stop Orders `. diff --git a/doc/source/netscript/tixapi/sellShort.rst b/doc/source/netscript/tixapi/sellShort.rst index 2d8291fa5..ca339f235 100644 --- a/doc/source/netscript/tixapi/sellShort.rst +++ b/doc/source/netscript/tixapi/sellShort.rst @@ -3,9 +3,10 @@ sellShort() Netscript Function .. js:function:: sellShort(sym, shares) + :RAM cost: 2.5 GB :param string sym: Symbol of stock to sell :param number shares: Number of shares to sell. Must be positive. Will be rounded to nearest integer - :RAM cost: 2.5 GB + Attempts to sell a `short `_ position of a stock using a `Market Order `_. diff --git a/doc/source/netscript/tixapi/sellStock.rst b/doc/source/netscript/tixapi/sellStock.rst index 7c5e66723..b7b76c5ab 100644 --- a/doc/source/netscript/tixapi/sellStock.rst +++ b/doc/source/netscript/tixapi/sellStock.rst @@ -3,9 +3,10 @@ sellStock() Netscript Function .. js:function:: sellStock(sym, shares) + :RAM cost: 2.5 GB :param string sym: Symbol of stock to sell :param number shares: Number of shares to sell. Must be positive. Will be rounded to nearest integer - :RAM cost: 2.5 GB + Attempts to sell shares of a stock using a `Market Order `_. diff --git a/doc/source/netscript/tixapi/shortStock.rst b/doc/source/netscript/tixapi/shortStock.rst index cd319cf88..4d623bcc8 100644 --- a/doc/source/netscript/tixapi/shortStock.rst +++ b/doc/source/netscript/tixapi/shortStock.rst @@ -3,9 +3,10 @@ shortStock() Netscript Function .. js:function:: shortStock(sym, shares) + :RAM cost: 2.5 GB :param string sym: Symbol of stock to short :param number shares: Number of shares to short. Must be positive. Will be rounded to nearest integer - :RAM cost: 2.5 GB + Attempts to purchase a `short `_ position of a stock using a `Market Order `_. diff --git a/src/Bladeburner.js b/src/Bladeburner.js index 75b5b1688..5730e8044 100644 --- a/src/Bladeburner.js +++ b/src/Bladeburner.js @@ -3511,12 +3511,10 @@ Bladeburner.prototype.getSkillNamesNetscriptFn = function() { } Bladeburner.prototype.startActionNetscriptFn = function(type, name, workerScript) { - var errorLogText = "ERROR: bladeburner.startAction() failed due to an invalid action specified. " + - "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " + - "name of the operation is case-sensitive."; - var actionId = this.getActionIdFromTypeAndName(type, name); + const errorLogText = `Invalid action: type='${type}' name='${name}'`; + const actionId = this.getActionIdFromTypeAndName(type, name); if (actionId == null) { - workerScript.log(errorLogText); + workerScript.log("bladeburner.startAction", errorLogText); return false; } @@ -3525,13 +3523,13 @@ Bladeburner.prototype.startActionNetscriptFn = function(type, name, workerScript // Can't start a BlackOp if you don't have the required rank let action = this.getActionObject(actionId); if (action.reqdRank > this.rank) { - workerScript.log(`Failed to start Black Op ${actionId.name} due to insufficient rank`); + workerScript.log("bladeburner.startAction", `Insufficient rank to start Black Op '${actionId.name}'.`); return false; } // Can't start a BlackOp if its already been done if (this.blackops[actionId.name] != null) { - workerScript.log(`Failed to start Black Op ${actionId.name} because its already been completed`); + workerScript.log("bladeburner.startAction", `Black Op ${actionId.name} has already been completed.`); return false; } @@ -3548,43 +3546,38 @@ Bladeburner.prototype.startActionNetscriptFn = function(type, name, workerScript let i = blackops.indexOf(actionId.name); if (i === -1) { - workerScript.log("ERROR: Invalid Black Operation name passed into bladeburner.startAction(). Note that this name is case-sensitive & whitespace-sensitive"); + workerScript.log("bladeburner.startAction", `Invalid Black Op: '${name}'`); return false; } if (i > 0 && this.blackops[blackops[i-1]] == null) { - workerScript.log(`ERROR: Cannot attempt Black Operation ${actionId.name} because you have not done the preceding one`); + workerScript.log("bladeburner.startAction", `Preceding Black Op must be completed before starting '${actionId.name}'.`); return false; } } try { this.startAction(actionId); - if (workerScript.shouldLog("startAction")) { - workerScript.log("Starting bladeburner action with type " + type + " and name " + name); - } + workerScript.log("bladeburner.startAction", `Starting bladeburner action with type '${type}' and name ${name}"`); return true; } catch(e) { this.resetAction(); - workerScript.log("ERROR: bladeburner.startAction() failed to start action of type " + type + " due to invalid name: " + name + - "Note that this name is case-sensitive and whitespace-sensitive"); + workerScript.log("bladeburner.startAction", errorLogText); return false; } } Bladeburner.prototype.getActionTimeNetscriptFn = function(type, name, workerScript) { - var errorLogText = "ERROR: bladeburner.getActionTime() failed due to an invalid action specified. " + - "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " + - "name of the operation is case-sensitive."; - var actionId = this.getActionIdFromTypeAndName(type, name); + const errorLogText = `Invalid action: type='${type}' name='${name}'` + const actionId = this.getActionIdFromTypeAndName(type, name); if (actionId == null) { - workerScript.log(errorLogText); + workerScript.log("bladeburner.getActionTime", errorLogText); return -1; } - var actionObj = this.getActionObject(actionId); + const actionObj = this.getActionObject(actionId); if (actionObj == null) { - workerScript.log(errorLogText); + workerScript.log("bladeburner.getActionTime", errorLogText); return -1; } @@ -3601,24 +3594,22 @@ Bladeburner.prototype.getActionTimeNetscriptFn = function(type, name, workerScri case ActionTypes["Recruitment"]: return this.getRecruitmentTime(); default: - workerScript.log(errorLogText); + workerScript.log("bladeburner.getActionTime", errorLogText); return -1; } } Bladeburner.prototype.getActionEstimatedSuccessChanceNetscriptFn = function(type, name, workerScript) { - var errorLogText = "ERROR: bladeburner.getActionEstimatedSuccessChance() failed due to an invalid action specified. " + - "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " + - "name of the operation is case-sensitive."; - var actionId = this.getActionIdFromTypeAndName(type, name); + const errorLogText = `Invalid action: type='${type}' name='${name}'` + const actionId = this.getActionIdFromTypeAndName(type, name); if (actionId == null) { - workerScript.log(errorLogText); + workerScript.log("bladeburner.getActionEstimatedSuccessChance", errorLogText); return -1; } - var actionObj = this.getActionObject(actionId); + const actionObj = this.getActionObject(actionId); if (actionObj == null) { - workerScript.log(errorLogText); + workerScript.log("bladeburner.getActionEstimatedSuccessChance", errorLogText); return -1; } @@ -3635,24 +3626,22 @@ Bladeburner.prototype.getActionEstimatedSuccessChanceNetscriptFn = function(type case ActionTypes["Recruitment"]: return this.getRecruitmentSuccessChance(); default: - workerScript.log(errorLogText); + workerScript.log("bladeburner.getActionEstimatedSuccessChance", errorLogText); return -1; } } Bladeburner.prototype.getActionCountRemainingNetscriptFn = function(type, name, workerScript) { - var errorLogText = "ERROR: bladeburner.getActionCountRemaining() failed due to an invalid action specified. " + - "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " + - "name of the operation is case-sensitive."; - var actionId = this.getActionIdFromTypeAndName(type, name); + const errorLogText = `Invalid action: type='${type}' name='${name}'`; + const actionId = this.getActionIdFromTypeAndName(type, name); if (actionId == null) { - workerScript.log(errorLogText); + workerScript.log("bladeburner.getActionCountRemaining", errorLogText); return -1; } - var actionObj = this.getActionObject(actionId); + const actionObj = this.getActionObject(actionId); if (actionObj == null) { - workerScript.log(errorLogText); + workerScript.log("bladeburner.getActionCountRemaining", errorLogText); return -1; } @@ -3672,21 +3661,14 @@ Bladeburner.prototype.getActionCountRemainingNetscriptFn = function(type, name, case ActionTypes["FieldAnalysis"]: return Infinity; default: - workerScript.log(errorLogText); + workerScript.log("bladeburner.getActionCountRemaining", errorLogText); return -1; } } Bladeburner.prototype.getSkillLevelNetscriptFn = function(skillName, workerScript) { - var errorLogText = "ERROR: bladeburner.getSkillLevel() failed due to an invalid skill specified: " + - skillName + ". Note that the name of the skill is case-sensitive"; - - if (skillName === "") { - return -1; - } - - if (!Skills.hasOwnProperty(skillName)) { - workerScript.log(errorLogText); + if (skillName === "" || !Skills.hasOwnProperty(skillName)) { + workerScript.log("bladeburner.getSkillLevel", `Invalid skill: '${skillName}'`); return -1; } @@ -3698,19 +3680,12 @@ Bladeburner.prototype.getSkillLevelNetscriptFn = function(skillName, workerScrip } Bladeburner.prototype.getSkillUpgradeCostNetscriptFn = function(skillName, workerScript) { - var errorLogText = "ERROR: bladeburner.getSkillUpgradeCostNetscriptFn() failed due to an invalid skill specified: " + - skillName + ". Note that the name of the skill is case-sensitive"; - - if (skillName === "") { + if (skillName === "" || !Skills.hasOwnProperty(skillName)) { + workerScript.log("bladeburner.getSkillUpgradeCost", `Invalid skill: '${skillName}'`); return -1; } - if (!Skills.hasOwnProperty(skillName)) { - workerScript.log(errorLogText); - return -1; - } - - var skill = Skills[skillName]; + const skill = Skills[skillName]; if (this.skills[skillName] == null) { return skill.calculateCost(0); } else { @@ -3719,33 +3694,26 @@ Bladeburner.prototype.getSkillUpgradeCostNetscriptFn = function(skillName, worke } Bladeburner.prototype.upgradeSkillNetscriptFn = function(skillName, workerScript) { - var errorLogText = "ERROR: bladeburner.upgradeSkill() failed due to an invalid skill specified: " + - skillName + ". Note that the name of the skill is case-sensitive"; + const errorLogText = `Invalid skill: '${skillName}'`; if (!Skills.hasOwnProperty(skillName)) { - workerScript.log(errorLogText); + workerScript.log("bladeburner.upgradeSkill", errorLogText); return false; } - var skill = Skills[skillName]; - var currentLevel = 0; + const skill = Skills[skillName]; + let currentLevel = 0; if (this.skills[skillName] && !isNaN(this.skills[skillName])) { currentLevel = this.skills[skillName]; } - var cost = skill.calculateCost(currentLevel); + const cost = skill.calculateCost(currentLevel); if(skill.maxLvl && currentLevel >= skill.maxLvl) { - if (workerScript.shouldLog("upgradeSkill")) { - workerScript.log(`bladeburner.upgradeSkill() failed because ${skillName} is already maxed`); - } + workerScript.log("bladeburner.upgradeSkill", `Skill '${skillName}' is already maxed.`); return false; } if (this.skillPoints < cost) { - if (workerScript.shouldLog("upgradeSkill")) { - workerScript.log("bladeburner.upgradeSkill() failed because you do not have enough " + - "skill points to upgrade " + skillName + " (You have " + - this.skillPoints + ", you need " + cost + ")"); - } + workerScript.log("bladeburner.upgradeSkill", `You do not have enough skill points to upgrade ${skillName} (You have ${this.skillPoints}, you need ${cost})`); return false; } @@ -3754,9 +3722,7 @@ Bladeburner.prototype.upgradeSkillNetscriptFn = function(skillName, workerScript if (routing.isOn(Page.Bladeburner) && DomElems.currentTab.toLowerCase() === "skills") { this.createActionAndSkillsContent(); } - if (workerScript.shouldLog("upgradeSkill")) { - workerScript.log(skillName + " successfully upgraded to level " + this.skills[skillName]); - } + workerScript.log("bladeburner.upgradeSkill", `'${skillName}' upgraded to level ${this.skills[skillName]}`); return true; } @@ -3765,19 +3731,16 @@ Bladeburner.prototype.getTeamSizeNetscriptFn = function(type, name, workerScript return this.teamSize; } - var errorLogText = "ERROR: bladeburner.getTeamSize() failed due to an invalid action specified. " + - "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " + - "name of the operation is case-sensitive."; - - var actionId = this.getActionIdFromTypeAndName(type, name); + const errorLogText = `Invalid action: type='${type}' name='${name}'`; + const actionId = this.getActionIdFromTypeAndName(type, name); if (actionId == null) { - workerScript.log(errorLogText); + workerScript.log("bladeburner.getTeamSize", errorLogText); return -1; } - var actionObj = this.getActionObject(actionId); + const actionObj = this.getActionObject(actionId); if (actionObj == null) { - workerScript.log(errorLogText); + workerScript.log("bladeburner.getTeamSize", errorLogText); return -1; } @@ -3791,39 +3754,34 @@ Bladeburner.prototype.getTeamSizeNetscriptFn = function(type, name, workerScript } Bladeburner.prototype.setTeamSizeNetscriptFn = function(type, name, size, workerScript) { - var errorLogText = "ERROR: bladeburner.setTeamSize() failed due to an invalid action specified. " + - "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " + - "name of the operation is case-sensitive."; - var actionId = this.getActionIdFromTypeAndName(type, name); + const errorLogText = `Invalid action: type='${type}' name='${name}'`; + const actionId = this.getActionIdFromTypeAndName(type, name); if (actionId == null) { - workerScript.log(errorLogText); + workerScript.log("bladeburner.setTeamSize", errorLogText); return -1; } if (actionId.type !== ActionTypes["Operation"] && actionId.type !== ActionTypes["BlackOp"] && actionId.type !== ActionTypes["BlackOperation"]) { - workerScript.log("ERROR: bladeburner.setTeamSize() failed. This function " + - "only works for Operations and BlackOps"); + workerScript.log("bladeburner.setTeamSize", "Only valid for 'Operations' and 'BlackOps'"); return -1; } - var actionObj = this.getActionObject(actionId); + const actionObj = this.getActionObject(actionId); if (actionObj == null) { - workerScript.log(errorLogText); + workerScript.log("bladeburner.setTeamSize", errorLogText); return -1; } - var sanitizedSize = Math.round(size); + const sanitizedSize = Math.round(size); if (isNaN(sanitizedSize)) { - workerScript.log("ERROR: bladeburner.setTeamSize() failed due to an invalid 'size' argument: " + size); + workerScript.log("bladeburner.setTeamSize", `Invalid size: ${size}`); return -1; } if (this.teamSize < sanitizedSize) {sanitizedSize = this.teamSize;} actionObj.teamCount = sanitizedSize; - if (workerScript.shouldLog("setTeamSize")) { - workerScript.log("Team size for " + name + " set to " + sanitizedSize); - } + workerScript.log("bladeburner.setTeamSize", `Team size for '${name}' set to ${sanitizedSize}.`); return sanitizedSize; } @@ -3833,19 +3791,14 @@ Bladeburner.prototype.joinBladeburnerFactionNetscriptFn = function(workerScript) return true; } else if (this.rank >= RankNeededForFaction) { joinFaction(bladeburnerFac); - if (workerScript.shouldLog("joinBladeburnerFaction")) { - workerScript.log("Joined Bladeburners Faction"); - } + workerScript.log("bladeburner.joinBladeburnerFaction", "Joined Bladeburners faction."); if (routing.isOn(Page.Bladeburner)) { removeChildrenFromElement(DomElems.overviewDiv); this.createOverviewContent(); } return true; } else { - if (workerScript.shouldLog("joinBladeburnerFaction")) { - workerScript.log("Failed to join Bladeburners Faction because " + - "you do not have the required " + RankNeededForFaction + " rank"); - } + workerScript.log("bladeburner.joinBladeburnerFaction", `You do not have the required rank (${this.rank}/${RankNeededForFaction}).`); return false; } } diff --git a/src/Netscript/WorkerScript.ts b/src/Netscript/WorkerScript.ts index 13ba99d57..23c5d48e6 100644 --- a/src/Netscript/WorkerScript.ts +++ b/src/Netscript/WorkerScript.ts @@ -190,10 +190,12 @@ export class WorkerScript { log(func: string, txt: string): void { if(this.shouldLog(func)) { - if(func !== "" && txt !== ""){ + if(func && txt){ this.scriptRef.log(`${func}: ${txt}`); + } else if(func) { + this.scriptRef.log(func); } else { - this.scriptRef.log(func+txt); + this.scriptRef.log(txt); } } }