mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-22 01:03:01 +02:00
Minor bug fixes, adding spotify music player, and adding sphinx documentation
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
.. Bitburner documentation master file, created by
|
||||
sphinx-quickstart on Wed Oct 4 15:03:07 2017.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to Bitburner's documentation!
|
||||
=====================================
|
||||
Bitburner is a cyberpunk-themed `incremental game <https://en.wikipedia.org/wiki/Incremental_game>`_ that is currently in the
|
||||
early beta stage of development. The game `can be played here <https://danielyxie.github.io/bitburner/>`_.
|
||||
|
||||
What is Bitburner?
|
||||
------------------
|
||||
Bitburner is a cyberpunk-themed incremental RPG where you, the player, take the role of an unknown hacker in a dark, dystopian world.
|
||||
When a mysterious hacker called jump3R messages you, he/she confirms your suspicions that there is something wrong with the world around you.
|
||||
Now, aided by jump3R, you embark on a quest to gain money and power by any means necessary, in the hopes that this will lead to to uncover the
|
||||
secrets that you've been searching for.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 5
|
||||
:caption: Contents:
|
||||
|
||||
Netscript <netscript>
|
||||
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
Netscript Documentation
|
||||
=======================
|
||||
Netscript is the programming language used in the world of Bitburner.
|
||||
|
||||
When you write scripts in Bitburner, they are written in the Netscript language.
|
||||
Netscript is simply a tiny subset of Javascript. This means that Netscript's
|
||||
syntax is almost idental to Javascript's, but it does not implement many of the
|
||||
features that Javascript has.
|
||||
|
||||
If you have any requests or suggestions to improve the Netscript language, feel free
|
||||
to reach out to the developer!
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 5
|
||||
:caption: Sections:
|
||||
|
||||
Data Types and Variables <netscriptdatatypes>
|
||||
Operators <netscriptoperators>
|
||||
Loops and Conditionals <netscriptloopsandconditionals>
|
||||
Script Arguments <netscriptscriptarguments>
|
||||
Basic Functions <netscriptfunctions>
|
||||
Advanced Functions <netscriptadvancedfunctions>
|
||||
Hacknet Node API <netscripthacknetnodeapi>
|
||||
Trade Information eXchange (TIX) API <netscriptixapi>
|
||||
Singularity Functions <netscriptsingularityfunctions>
|
||||
@@ -0,0 +1,45 @@
|
||||
Netscript Advanced Functions
|
||||
============================
|
||||
|
||||
These Netscript functions become relevant later on in the game. They are put on a separate page because
|
||||
they contain spoilers for the game.
|
||||
|
||||
getBitNodeMultipliers
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. 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 integer 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 object has the following structure,
|
||||
(subject to change in the future)::
|
||||
|
||||
{
|
||||
ServerMaxMoney: 1,
|
||||
ServerStartingMoney: 1,
|
||||
ServerGrowthRate: 1,
|
||||
ServerWeakenRate: 1,
|
||||
ServerStartingSecurity: 1,
|
||||
ManualHackMoney: 1,
|
||||
ScriptHackMoney: 1,
|
||||
CompanyWorkMoney: 1,
|
||||
CrimeMoney: 1,
|
||||
HacknetNodeMoney: 1,
|
||||
CompanyWorkExpGain: 1,
|
||||
ClassGymExpGain: 1,
|
||||
FactionWorkExpGain: 1,
|
||||
HackExpGain: 1,
|
||||
CrimeExpGain: 1,
|
||||
FactionWorkRepGain: 1,
|
||||
FactionPassiveRepGain: 1,
|
||||
AugmentationRepCost: 1,
|
||||
AugmentationMoneyCost: 1,
|
||||
}
|
||||
|
||||
Example::
|
||||
|
||||
mults = getBitNodeMultipliers();
|
||||
print(mults.ServerMaxMoney);
|
||||
print(mults.HackExpGain);
|
||||
@@ -0,0 +1,44 @@
|
||||
Netscript Data Types and Variables
|
||||
==================================
|
||||
|
||||
|
||||
Data Types
|
||||
----------
|
||||
Netscript supports three primitive data types:
|
||||
|
||||
**Numbers** - Positive numerics, such as integers and floats. Examples: 6, 0, 10.5
|
||||
|
||||
**Strings** - A sequence of characters that represents text. The characters must be encapsulated by single or
|
||||
double quotes. Example: "This is a string" or equivalently 'This is a string'.
|
||||
*Strings are fully functional* `Javascript strings <https://www.w3schools.com/jsref/jsref_obj_string.asp>`_,
|
||||
*which means that all of the member functions of Javascript strings such as toLowerCase() and includes() are also available in Netscript!*
|
||||
|
||||
**Boolean** - true or false
|
||||
|
||||
**Array** - An array is a special container object that is capable of holding many different values. Arrays are simply Javascript
|
||||
arrays, and most Javascript array methods can be used in Netscript as well (join(), pop(), splice(), etc.). You can read more about
|
||||
`Javascript arrays here <https://www.w3schools.com/js/js_arrays.asp>`_
|
||||
|
||||
Variables
|
||||
---------
|
||||
|
||||
Variables can be thought of as named containers. Their purpose is to label and store data. The data stored in the
|
||||
variable can then be accessed and changed by referring to the variable's name. The name of a variable must start with
|
||||
either a letter or an underscore. The rest of the variable name can contain any alphanumeric (letters and numbers),
|
||||
as well as hyphens and underscores.
|
||||
|
||||
The Netscript language is untyped, meaning that any variable can hold any of the data types above. The value type of a variable
|
||||
can also change. For example, if a variable initially holds a number, it can later hold a string.
|
||||
|
||||
The following shows how you can declare and initialize variables::
|
||||
|
||||
i = 1;
|
||||
s = "This is a string";
|
||||
b = false;
|
||||
|
||||
After declaring a variable, the values in variables can be used simply by referencing the name. For example::
|
||||
|
||||
j = i + 5;
|
||||
s2 = s + " Adding more letters onto the string"
|
||||
|
||||
The first command above will store the value 6 in the variable j. The second command will store the string "This is a string Adding more letters onto the string" into the variable s2.
|
||||
+889
@@ -0,0 +1,889 @@
|
||||
Netscript Basic Functions
|
||||
=========================
|
||||
|
||||
This page contains the complete documentation for all functions that are available in Netscript.
|
||||
This includes information such as function signatures, what they do, and their return values.
|
||||
|
||||
At the end is also a section that describes how to define your own functions in Netscript.
|
||||
|
||||
hack
|
||||
^^^^
|
||||
|
||||
.. js:function:: hack(hostname/ip)
|
||||
|
||||
:param string hostname/ip: IP or hostname of the target server to hack
|
||||
:returns: True if the hack is successful, false otherwise
|
||||
|
||||
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 successful hack() on a server will raise that server's security level by 0.002.
|
||||
|
||||
Example::
|
||||
|
||||
hack("foodnstuff");
|
||||
hack("10.1.2.3");
|
||||
|
||||
grow
|
||||
^^^^
|
||||
|
||||
.. js:function:: grow(hostname/ip)
|
||||
|
||||
:param string hostname/ip: IP or hostname of the target server to grow
|
||||
:returns: The number by which the money on the server was multiplied for the growth
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Example::
|
||||
|
||||
grow("foodnstuff");
|
||||
|
||||
weaken
|
||||
^^^^^^
|
||||
|
||||
.. js:function:: weaken(hostname/ip)
|
||||
|
||||
:param string hostname.ip: IP or hostname of the target server to weaken
|
||||
: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
|
||||
|
||||
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 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::
|
||||
|
||||
weaken("foodnstuff");
|
||||
|
||||
sleep
|
||||
^^^^^
|
||||
|
||||
.. js:function:: sleep(n[, log=true])
|
||||
|
||||
:param number n: Number of milliseconds to sleep
|
||||
:param boolean log: Optional boolean specifying whether or not to log the action
|
||||
|
||||
Suspends the script for n milliseconds.
|
||||
|
||||
print
|
||||
^^^^^
|
||||
|
||||
.. js:function:: print(x)
|
||||
|
||||
:param x: Value to be printed
|
||||
|
||||
Prints a value or a variable to the script's logs.
|
||||
|
||||
tprint
|
||||
^^^^^^
|
||||
|
||||
.. js:function:: tprint(x)
|
||||
|
||||
:param x: Value to be printed
|
||||
|
||||
Prints a value or a variable to the Terminal
|
||||
|
||||
scan
|
||||
^^^^
|
||||
|
||||
.. js:function:: scan(hostname/ip[, hostnames=true])
|
||||
|
||||
: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)
|
||||
|
||||
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.
|
||||
|
||||
nuke
|
||||
^^^^
|
||||
|
||||
.. js:function:: nuke(hostname/ip)
|
||||
|
||||
:param string hostname/ip: IP or hostname of the target server
|
||||
|
||||
Runs the NUKE.exe program on the target server. NUKE.exe must exist on your home computer.
|
||||
|
||||
Example::
|
||||
|
||||
nuke("foodnstuff");
|
||||
|
||||
brutessh
|
||||
^^^^^^^^
|
||||
|
||||
.. js:function:: brutessh(hostname/ip)
|
||||
|
||||
:param string hostname/ip: IP or hostname of the target server
|
||||
|
||||
Runs the BruteSSH.exe program on the target server. BruteSSH.exe must exist on your home computer.
|
||||
|
||||
Example::
|
||||
|
||||
brutessh("foodnstuff");
|
||||
|
||||
ftpcrack
|
||||
^^^^^^^^
|
||||
|
||||
.. js:function:: ftpcrack(hostname/ip)
|
||||
|
||||
:param string hostname/ip: IP or hostname of the target server
|
||||
|
||||
Runs the FTPCrack.exe program on the target server. FTPCrack.exe must exist on your home computer.
|
||||
|
||||
Example::
|
||||
|
||||
ftpcrack("foodnstuff");
|
||||
|
||||
relaysmtp
|
||||
^^^^^^^^^
|
||||
|
||||
.. js:function:: relaysmtp(hostname/ip)
|
||||
|
||||
:param string hostname/ip: IP or hostname of the target server
|
||||
|
||||
Runs the relaySMTP.exe program on the target server. relaySMTP.exe must exist on your home computer.
|
||||
|
||||
Example::
|
||||
|
||||
relaysmtp("foodnstuff");
|
||||
|
||||
httpworm
|
||||
^^^^^^^^
|
||||
|
||||
.. js:function:: httpworm(hostname/ip)
|
||||
|
||||
:param string hostname/ip: IP or hostname of the target server
|
||||
|
||||
Runs the HTTPWorm.exe program on the target server. HTTPWorm.exe must exist on your home computer.
|
||||
|
||||
Example::
|
||||
|
||||
httpworm("foodnstuff");
|
||||
|
||||
sqlinject
|
||||
^^^^^^^^^
|
||||
|
||||
.. js:function:: sqlinject(hostname/ip)
|
||||
|
||||
:param string hostname/ip: IP or hostname of the target server
|
||||
|
||||
Runs the SQLInject.exe program on the target server. SQLInject.exe must exist on your home computer.
|
||||
|
||||
Example::
|
||||
|
||||
sqlinject("foodnstuff");
|
||||
|
||||
run
|
||||
^^^
|
||||
|
||||
.. 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.
|
||||
|
||||
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).
|
||||
|
||||
Returns true if the script is successfully started, and false otherwise. Requires a significant amount of RAM to run this
|
||||
command.
|
||||
|
||||
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::
|
||||
|
||||
run("foo.script");
|
||||
|
||||
The following example will run 'foo.script' but with 5 threads instead of single-threaded::
|
||||
|
||||
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::
|
||||
|
||||
run("foo.script", 1, 'foodnstuff');
|
||||
|
||||
exec
|
||||
^^^^
|
||||
|
||||
.. js:function:: exec(script, hostname/ip, [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.
|
||||
|
||||
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.
|
||||
|
||||
Returns true if the script is successfully started, and false otherwise.
|
||||
|
||||
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::
|
||||
|
||||
exec("generic-hack.script", "foodnstuff");
|
||||
|
||||
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::
|
||||
|
||||
exec("foo.script", "foodnstuff", 5, 1, "test");
|
||||
|
||||
kill
|
||||
^^^^
|
||||
|
||||
.. js:function:: kill(script, hostname/ip, [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
|
||||
|
||||
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.
|
||||
|
||||
Examples:
|
||||
|
||||
The following example will try to kill a script named *foo.script* on the *foodnstuff* server that was ran with no arguments::
|
||||
|
||||
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::
|
||||
|
||||
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"::
|
||||
|
||||
kill("foo.script", getHostname(), 1, "foodnstuff");
|
||||
|
||||
killall
|
||||
^^^^^^^
|
||||
|
||||
.. js:function:: killall(hostname/ip)
|
||||
|
||||
:param string hostname/ip: IP or hostname of the server on which to kill all scripts
|
||||
|
||||
Kills all running scripts on the specified server. This function will always return true.
|
||||
|
||||
|
||||
exit
|
||||
^^^^
|
||||
|
||||
.. js:function:: exit()
|
||||
|
||||
Terminates the current script immediately
|
||||
|
||||
scp
|
||||
^^^
|
||||
|
||||
.. js:function:: scp(files, [source], destination)
|
||||
|
||||
: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.
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Examples::
|
||||
|
||||
//Copies hack-template.script from the current server to foodnstuff
|
||||
scp("hack-template.script", "foodnstuff");
|
||||
|
||||
//Copies foo.lit from the helios server to the home computer
|
||||
scp("foo.lit", "helios", "home");
|
||||
|
||||
//Tries to copy three files from rothman-uni to home computer
|
||||
files = ["foo1.lit", "foo2.script", "foo3.script"];
|
||||
scp(files, "rothman-uni", "home");
|
||||
|
||||
ls
|
||||
^^
|
||||
|
||||
.. js:function:: ls(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP of the target server
|
||||
|
||||
Returns an array with the filenames of all files on the specified server (as strings). The returned array
|
||||
is sorted in alphabetic order
|
||||
|
||||
hasRootAccess
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: hasRootAccess(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP of the target server
|
||||
|
||||
Returns a boolean indicating whether or not the player has root access to the specified target server.
|
||||
|
||||
Example::
|
||||
|
||||
if (hasRootAccess("foodnstuff") == false) {
|
||||
nuke("foodnstuff");
|
||||
}
|
||||
|
||||
getHostname
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getHostname()
|
||||
|
||||
Returns a string with the hostname of the server that the script is running on
|
||||
|
||||
getHackingLevel
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getHackingLevel()
|
||||
|
||||
Returns the player's current hacking level
|
||||
|
||||
getHackingMultipliers
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getHackingMultipliers()
|
||||
|
||||
Returns an object containing the Player's hacking related multipliers. These multipliers are
|
||||
returned in integer forms, not percentages (e.g. 1.5 instead of 150%). The object has the following structure::
|
||||
|
||||
{
|
||||
chance: Player's hacking chance multiplier,
|
||||
speed: Player's hacking speed multiplier,
|
||||
money: Player's hacking money stolen multiplier,
|
||||
growth: Player's hacking growth multiplier
|
||||
}
|
||||
|
||||
Example of how this can be used::
|
||||
|
||||
mults = getHackingMultipliers();
|
||||
print(mults.chance);
|
||||
print(mults.growth);
|
||||
|
||||
getServerMoneyAvailable
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getServerMoneyAvailable(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
|
||||
Returns the amount of money available on a server. **Running this function on the home computer will return
|
||||
the player's money.**
|
||||
|
||||
Example::
|
||||
|
||||
getServerMoneyAvailable("foodnstuff");
|
||||
getServerMoneyAvailable("home"); //Returns player's money
|
||||
|
||||
getServerMaxMoney
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getServerMaxMoney(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
|
||||
Returns the maximum amount of money that can be available on a server
|
||||
|
||||
getServerGrowth
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getServerGrowth(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
|
||||
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()*.
|
||||
|
||||
getServerSecurityLevel
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getServerSecurityLevel(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP of 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).
|
||||
|
||||
getServerBaseSecurityLevel
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getServerBaseSecurityLevel(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP 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).
|
||||
|
||||
getServerMinSecurityLevel
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getServerMinSecurityLevel(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
|
||||
Returns the minimum security level of the target server
|
||||
|
||||
getServerRequiredHackingLevel
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getServerRequiredHackingLevel(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
|
||||
Returns the required hacking level of the target server
|
||||
|
||||
getServerNumPortsRequired
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getServerNumPortsRequired(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
|
||||
Returns the number of open ports required to successfully run NUKE.exe on the specified server.
|
||||
|
||||
getServerRam
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getServerRam(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
|
||||
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::
|
||||
|
||||
res = getServerRam("helios");
|
||||
totalRam = res[0];
|
||||
ramUsed = res[1];
|
||||
|
||||
serverExists
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: serverExists(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
|
||||
Returns a boolean denoting whether or not the specified server exists
|
||||
|
||||
fileExists
|
||||
^^^^^^^^^^
|
||||
|
||||
.. js:function:: fileExists(filename, [hostname/ip])
|
||||
|
||||
: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
|
||||
|
||||
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".
|
||||
|
||||
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.
|
||||
|
||||
Examples::
|
||||
|
||||
fileExists("foo.script", "foodnstuff");
|
||||
fileExists("ftpcrack.exe");
|
||||
|
||||
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.
|
||||
|
||||
isRunning
|
||||
^^^^^^^^^
|
||||
|
||||
.. js:function:: isRunning(filename, hostname/ip, [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
|
||||
|
||||
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.
|
||||
|
||||
**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::
|
||||
|
||||
isRunning("foo.script", "foodnstuff");
|
||||
|
||||
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", 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::
|
||||
|
||||
isRunning("foo.script", "joesguns", 1, 5, "test");
|
||||
|
||||
getNextHacknetNodeCost
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getNextHacknetNodeCost()
|
||||
|
||||
Returns the cost of purchasing a new Hacknet Node
|
||||
|
||||
purchaseHacknetNode
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: purchaseHacknetNode()
|
||||
|
||||
Purchases a new Hacknet Node. Returns a number with the index of the 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 false.
|
||||
|
||||
purchaseServer
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
.. 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 (2, 4, 8, 16, etc.)
|
||||
|
||||
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.
|
||||
|
||||
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::
|
||||
|
||||
ram = 64;
|
||||
hn = "pserv-";
|
||||
for (i = 0; i < 5; ++i) {
|
||||
purchaseServer(hn + i, ram);
|
||||
}
|
||||
|
||||
deleteServer
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: deleteServer(hostname)
|
||||
|
||||
:param string hostname: Hostname of the server to delete
|
||||
|
||||
Deletes one of your purchased servers, which is specified by its hostname.
|
||||
|
||||
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.
|
||||
|
||||
getPurchasedServers
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getPurchasedServers([hostname=true])
|
||||
|
||||
: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
|
||||
|
||||
Returns an array with either the hostnames or IPs of all of the servers you have purchased.
|
||||
|
||||
round
|
||||
^^^^^
|
||||
|
||||
.. js:function:: round(n)
|
||||
|
||||
:param number n: Number to round
|
||||
|
||||
Returns the argument *n* rounded to the nearest integer. If the argument passed in is not a number, then the function will return 0.
|
||||
|
||||
write
|
||||
^^^^^
|
||||
|
||||
.. js:function:: write(port/fn, data="", mode="a")
|
||||
|
||||
:param string/number port/fn: Port or text file 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.
|
||||
|
||||
This function can be used to either write data to a port or to a text file (.txt).
|
||||
|
||||
If the first argument is a number between 1 and 10, then it specifies a port and this function will write *data* to that port. Read
|
||||
about how `Netscript Ports work here <http://bitburner.wikia.com/wiki/Netscript_Ports>`_. 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 (.txt) and this function will write *data* to that text file. If the
|
||||
specified text file does not exist, then it will be created. The third argument *mode, defines how the data will be written to the text file. 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. 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 text file.
|
||||
|
||||
read
|
||||
^^^^
|
||||
|
||||
.. js:function:: read(port/fn)
|
||||
|
||||
:param string/number port/fn: Port or text file to read from
|
||||
|
||||
This function is used to read data from a port or from a text file (.txt).
|
||||
|
||||
If the argument *port/fn* is a number between 1 and 10, then it specifies a port and it will read data from that port. Read
|
||||
about how `Netscript Ports work here <http://bitburner.wikia.com/wiki/Netscript_Ports>`_. 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 (.txt) and this function will return the data in the specified text file. If
|
||||
the text file does not exist, an empty string will be returned.
|
||||
|
||||
clear
|
||||
^^^^^
|
||||
|
||||
.. js:function:: clear(port/fn)
|
||||
|
||||
:param string/number port/fn: Port or text file to clear
|
||||
|
||||
This function is used to clear data in a `Netscript Ports <http://bitburner.wikia.com/wiki/Netscript_Ports>`_ or a text file.
|
||||
|
||||
If the *port/fn* argument is a number between 1 and 10, 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.
|
||||
|
||||
scriptRunning
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: scriptRunning(scriptname, hostname/ip)
|
||||
|
||||
:param string scriptname: Filename of script to check. This is case-sensitive.
|
||||
:param string hostname/ip: Hostname or IP of target 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 *isRunning()* function because it does not try to identify a specific instance of a running script
|
||||
by its arguments.
|
||||
|
||||
**Examples:**
|
||||
|
||||
The example below will return true if there is any script named *foo.script* running on the *foodnstuff* server, and false otherwise::
|
||||
|
||||
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::
|
||||
|
||||
scriptRunning("foo.script", getHostname());
|
||||
|
||||
scriptKill
|
||||
^^^^^^^^^^
|
||||
|
||||
.. js:function:: scriptKill(scriptname, hostname/ip)
|
||||
|
||||
:param string scriptname: Filename of script to kill. This is case-sensitive.
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
|
||||
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.
|
||||
|
||||
getScriptRam
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getScriptRam(scriptname, hostname/ip)
|
||||
|
||||
:param string scriptname: Filename of script. This is case-sensitive.
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
|
||||
Returns the amount of RAM required to run the specified script on the target server
|
||||
|
||||
getHackTime
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getHackTime(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
|
||||
Returns the amount of time in seconds it takes to execute the *hack()* Netscript function on the target server.
|
||||
|
||||
getGrowTime
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getGrowTime(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
|
||||
Returns the amount of time in seconds it takes to execute the *grow()* Netscript function on the target server.
|
||||
|
||||
getWeakenTime
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getWeakenTime(hostname/ip)
|
||||
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
|
||||
Returns the amount of time in seconds it takes to execute the *weaken()* Netscript function on the target server.
|
||||
|
||||
getScriptIncome
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getScriptIncome([scriptname], [hostname/ip], [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
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
getScriptExpGain
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getScriptExpGain([scriptname], [hostname/ip], [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
|
||||
|
||||
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.
|
||||
|
||||
getTimeSinceLastAug
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getTimeSinceLastAug()
|
||||
|
||||
Returns the amount of time in milliseconds that have passed since you last installed Augmentations
|
||||
|
||||
sprintf
|
||||
^^^^^^^
|
||||
|
||||
.. js:function:: sprintf()
|
||||
|
||||
See `this link <https://github.com/alexei/sprintf.js>`_ for details.
|
||||
|
||||
vsprintf
|
||||
^^^^^^^^
|
||||
|
||||
.. js:function:: vsprintf()
|
||||
|
||||
See `this link <https://github.com/alexei/sprintf.js>`_ for details.
|
||||
|
||||
prompt
|
||||
^^^^^^
|
||||
|
||||
.. js:function:: prompt(txt)
|
||||
|
||||
:param string txt: Text to appear in the prompt dialog box
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Defining your own Functions
|
||||
---------------------------
|
||||
|
||||
You can define your own functions in Netscript using the following syntax::
|
||||
|
||||
function name(args...) {
|
||||
function code here...
|
||||
return some_value
|
||||
}
|
||||
|
||||
Functions should have some return value. Here is an example of defining and using a function::
|
||||
|
||||
function sum(values) {
|
||||
res = 0;
|
||||
for (i = 0; i < values.length; ++i) {
|
||||
res += values[i];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
print(sum([1, 2, 3, 4, 5]));
|
||||
print(sum([1, 10]));
|
||||
|
||||
The example above prints the following in its log::
|
||||
|
||||
15
|
||||
11
|
||||
|
||||
**Note about variable scope in functions:**
|
||||
|
||||
Functions can access "global" variables declared outside of the function's scope. However, they cannot change the value of any "global" variables.
|
||||
Any changes to "global" variables will only be applied locally to the function. This also means that any variable that is first defined inside a
|
||||
function will NOT be accessible outside of the function.
|
||||
|
||||
For example, the following code::
|
||||
|
||||
function sum(values) {
|
||||
res = 0;
|
||||
for (i = 0; i < values.length; ++i) {
|
||||
res += values[i];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
print(res);
|
||||
|
||||
results in the following runtime error::
|
||||
|
||||
Script runtime error:
|
||||
Server Ip: 75.7.4.1
|
||||
Script name: test.script
|
||||
Args:[]
|
||||
variable res not defined
|
||||
|
||||
The following example shows that any change to "global" variable inside a function only applies in the function's local scope::
|
||||
|
||||
function foo() {
|
||||
i = 5;
|
||||
return "foo";
|
||||
}
|
||||
|
||||
i = 0;
|
||||
print(i);
|
||||
foo();
|
||||
print(i);
|
||||
|
||||
Results in the following log::
|
||||
|
||||
0
|
||||
0
|
||||
|
||||
**Other Notes about creating your own functions:**
|
||||
|
||||
Defining a function does not create a Javascript function object in the underlying game code. This means that you cannot use any function
|
||||
you create in functions such as `Array.sort() <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort>`_ (not yet at least, I'll try to make it work in the future).
|
||||
@@ -0,0 +1,127 @@
|
||||
Netscript Hacknet Node API
|
||||
==========================
|
||||
|
||||
Netscript provides the following API for accessing and upgrading your Hacknet Nodes
|
||||
through scripts.
|
||||
|
||||
Note that none of these functions will write to the script's logs. If you want
|
||||
to see what your script is doing you will have to print to the logs yourself.
|
||||
|
||||
hacknetnodes
|
||||
^^^^^^^^^^^^
|
||||
|
||||
*hacknetnodes* is a special variable. It is an array that maps to the player's
|
||||
Hacknet Nodes. The Hacknet Nodes are accessed through indexed. These indexes
|
||||
correspond to the number at the end of the name of the Hacknet Node. For example,
|
||||
the first Hacknet Node you purchase will have the name "hacknet-node-0" and can be
|
||||
accessed using *hacknetnodes[0]*. The fourth Hacknet Node you purchase will have the name
|
||||
"hacknet-node-3" and can be accessed using *hacknetnodes[3]*.
|
||||
|
||||
Hacknet Node Member Variables
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The following is a list of member variables for a Hacknet Node object. These variables are read-only, which means you cannot assign
|
||||
a value to these.
|
||||
|
||||
Note that these must be called on an element inside the *hacknetnodes* array, not the array itself.
|
||||
|
||||
.. js:function:: hacknetnodes[i].level
|
||||
|
||||
Returns the level of the corresponding Hacknet Node
|
||||
|
||||
.. js:function:: hacknetnodes[i].ram
|
||||
|
||||
Returns the amount of RAM on the corresponding Hacknet Node
|
||||
|
||||
.. js:function:: hacknetnodes[i].cores
|
||||
|
||||
Returns the number of cores on the corresponding Hacknet Node
|
||||
|
||||
.. js:function:: hacknetnodes[i].totalMoneyGenerated
|
||||
|
||||
Returns the total amount of money that the corresponding Hacknet Node has earned
|
||||
|
||||
.. js:function:: hacknetnodes[i].onlineTimeSeconds
|
||||
|
||||
Returns the total amount of time (in seconds) that the corresponding Hacknet Node has existed
|
||||
|
||||
.. js:function:: hacknetnodes[i].moneyGainRatePerSecond
|
||||
|
||||
Returns the amount of income that the corresponding Hacknet Node earns
|
||||
|
||||
Hacknet Node Methods
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The following is a list of supported functions/methods for a Hacknet Node object.
|
||||
|
||||
Note that these must be called on an element inside the *hacknetnodes* array, not the
|
||||
array itself.
|
||||
|
||||
.. js:function:: hacknetnodes[i].upgradeLevel(n);
|
||||
|
||||
:param number n: Number of levels to upgrade. Must be positive. Rounded to nearest integer
|
||||
|
||||
Tries to upgrade the level of the corresponding Hacknet Node *n* times. Returns true if the
|
||||
Hacknet Node's level is successfully upgraded *n* times or up to the max level (200), and false
|
||||
otherwise.
|
||||
|
||||
.. js:function:: hacknetnodes[i].upgradeRam()
|
||||
|
||||
Tries to upgrade the amount of RAM on the corresponding Hacknet Node. Returns true if the RAM is
|
||||
successfully upgraded and false otherwise.
|
||||
|
||||
.. js:function:: hacknetnodes[i].upgradeCore()
|
||||
|
||||
Tries to purchase an additional core for the corresponding Hacknet Node. Returns true if the
|
||||
additional core is successfully purchased, and false otherwise.
|
||||
|
||||
.. js:function:: hacknetnodes[i].getLevelUpgradeCost(n);
|
||||
|
||||
:param number n: Number of levels to upgrade. Must be positive. Rounded to nearest integer
|
||||
|
||||
Returns the cost of upgrading the specified Hacknet Node by *n* levels
|
||||
|
||||
.. js:function:: hacknetnodes[i].getRamUpgradeCost()
|
||||
|
||||
Returns the cost of upgrading the RAM of the specified Hacknet Node. Upgrading a Node's RAM doubles it.
|
||||
|
||||
.. js:function:: hacknetnodes[i].getCoreUpgradeCost()
|
||||
|
||||
Returns the cost of upgrading the number of cores of the specified Hacknet Node. Upgrading a Node's
|
||||
number of cores adds one additional core.
|
||||
|
||||
Example(s)
|
||||
^^^^^^^^^^
|
||||
|
||||
The following is an example of one way a script can be used to automate the purchasing and upgrading of Hacknet Nodes.
|
||||
This script purchases new Hacknet Nodes until the player has four. Then, it iteratively upgrades each of those four Hacknet
|
||||
Nodes to a level of at least 75, RAM to at least 8GB, and number of cores to at least 2::
|
||||
|
||||
//Purchase 4 Hacknet Nodes
|
||||
while(hacknetnodes.length < 4) {
|
||||
purchaseHacknetNode();
|
||||
}
|
||||
|
||||
//Upgrade all 4 Hacknet Nodes to at least level 75
|
||||
for (i = 0; i < 4; i = i++) {
|
||||
while (hacknetnodes[i].level <= 75) {
|
||||
hacknetnodes[i].upgradeLevel(5);
|
||||
sleep(10000);
|
||||
}
|
||||
}
|
||||
|
||||
//Upgrade RAM on all Hacknet Nodes to 8GB
|
||||
for (i = 0; i < 4; i = i++) {
|
||||
while (hacknetnodes[i].ram < 8) {
|
||||
hacknetnodes[i].upgradeRam();
|
||||
sleep(10000);
|
||||
}
|
||||
}
|
||||
|
||||
//Upgrade cores on all Hacknet Nodes to 2
|
||||
for (i = 0; i < 4; i = i++) {
|
||||
while (hacknetnodes[i].cores < 2) {
|
||||
hacknetnodes[i].upgradeCore();
|
||||
sleep(10000);
|
||||
}
|
||||
}
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
Netscript Trade Information eXchange (TIX) API
|
||||
==============================================
|
||||
|
||||
The Trade Information eXchange (TIX) is the communications protocol supported by the World Stock Exchange (WSE).
|
||||
The WESE provides an API that allows you to automatically communicate with the
|
||||
`Stock Market <http://bitburner.wikia.com/wiki/Stock_Market>`_. This API lets you write code using Netscript
|
||||
to build automated trading systems and create your own algorithmic trading strategies. Access to this
|
||||
TIX API can be purchased by visiting the World Stock Exchange in-game.
|
||||
|
||||
Access to the TIX API currently costs $5 billion. After you purchase it, you will retain this
|
||||
access even after you 'reset' by installing Augmentations
|
||||
|
||||
getStockPrice
|
||||
-------------
|
||||
|
||||
.. js:function:: getStockPrice(sym)
|
||||
|
||||
:param string sym: Stock symbol
|
||||
|
||||
Returns the price of a stock, given its symbol (NOT the company name). The symbol is a sequence
|
||||
of two to four capital letters.
|
||||
|
||||
Example::
|
||||
|
||||
getStockPrice("FISG");
|
||||
|
||||
getStockPosition
|
||||
----------------
|
||||
|
||||
.. js:function:: getStockPosition(sym)
|
||||
|
||||
:param string sym: Stock symbol
|
||||
|
||||
Returns an array of four elements that represents the player's position in a stock.
|
||||
|
||||
The first element is the returned array is the number of shares the player owns of the stock in the
|
||||
`Long position <http://bitburner.wikia.com/wiki/Stock_Market#Positions:_Long_vs_Short>`_. The second
|
||||
element in the array is the average price of the player's shares in the Long position.
|
||||
|
||||
The third element in the array is the number of shares the player owns of the stock in the
|
||||
`Short position <http://bitburner.wikia.com/wiki/Stock_Market#Positions:_Long_vs_Short>`_. The fourth
|
||||
element in the array is the average price of the player's Short position.
|
||||
|
||||
All elements in the returned array are numeric.
|
||||
|
||||
Example::
|
||||
|
||||
pos = getStockPosition("ECP");
|
||||
shares = pos[0];
|
||||
avgPx = pos[1];
|
||||
sharesShort = pos[2];
|
||||
avgPxShort = pos[3];
|
||||
|
||||
buyStock
|
||||
--------
|
||||
|
||||
.. js:function:: buyStock(sym, shares)
|
||||
|
||||
: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
|
||||
|
||||
Attempts to purchase shares of a stock using a `Market Order <http://bitburner.wikia.com/wiki/Stock_Market#Order_Types>`_.
|
||||
|
||||
If the player does not have enough money to purchase the specified number of shares, then no shares will be purchased. Remember
|
||||
that every transaction on the stock exchange costs a certain commission fee.
|
||||
|
||||
If this function successfully purchases the shares, it will return the stock price at which each share was purchased. Otherwise,
|
||||
it will return 0.
|
||||
|
||||
sellStock
|
||||
---------
|
||||
|
||||
.. js:function:: sellStock(sym, shares)
|
||||
|
||||
: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
|
||||
|
||||
Attempts to sell shares of a stock using a `Market Order <http://bitburner.wikia.com/wiki/Stock_Market#Order_Types>`_.
|
||||
|
||||
If the specified number of shares in the function exceeds the amount that the player actually owns, then this function will
|
||||
sell all owned shares. Remember that every transaction on the stock exchange costs a certain commission fee.
|
||||
|
||||
The net profit made from selling stocks with this function is reflected in the script's statistics.
|
||||
This net profit is calculated as::
|
||||
|
||||
shares * (sell price - average price of purchased shares)
|
||||
|
||||
If the sale is successful, this function will return the stock price at which each share was sold. Otherwise, it will return 0.
|
||||
|
||||
shortStock
|
||||
----------
|
||||
|
||||
.. js:function:: shortStock(sym, shares)
|
||||
|
||||
: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
|
||||
|
||||
Attempts to purchase a `short <http://bitburner.wikia.com/wiki/Stock_Market#Positions:_Long_vs_Short>`_ position of a stock
|
||||
using a `Market Order <http://bitburner.wikia.com/wiki/Stock_Market#Order_Types>`_.
|
||||
|
||||
The ability to short a stock is **not** immediately available to the player and must be unlocked later on in the game.
|
||||
|
||||
If the player does not have enough money to purchase the specified number of shares, then no shares will be purchased.
|
||||
Remember that every transaction on the stock exchange costs a certain commission fee.
|
||||
|
||||
If the purchase is successful, this function will return the stock price at which each share was purchased. Otherwise, it will return 0.
|
||||
|
||||
sellShort
|
||||
---------
|
||||
|
||||
.. js:function:: sellShort(sym, shares)
|
||||
|
||||
: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
|
||||
|
||||
Attempts to sell a `short <http://bitburner.wikia.com/wiki/Stock_Market#Positions:_Long_vs_Short>`_ position of a stock
|
||||
using a `Market Order <http://bitburner.wikia.com/wiki/Stock_Market#Order_Types>`_.
|
||||
|
||||
The ability to short a stock is **not** immediately available to the player and must be unlocked later on in the game.
|
||||
|
||||
If the specified number of shares exceeds the amount that the player actually owns, then this function will sell all owned
|
||||
shares. Remember that every transaction on the stock exchange costs a certain commission fee.
|
||||
|
||||
If the sale is successful, this function will return the stock price at which each share was sold. Otherwise it will return 0.
|
||||
|
||||
placeOrder
|
||||
----------
|
||||
|
||||
.. js:function:: placeOrder(sym, shares, price, type, pos)
|
||||
|
||||
: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
|
||||
:param string type: Type of order. It must specify "limit" or "stop", and must also specify "buy" or "sell". This is NOT
|
||||
case-sensitive. Here are four examples that will work:
|
||||
|
||||
* limitbuy
|
||||
* limitsell
|
||||
* stopbuy
|
||||
* stopsell
|
||||
|
||||
: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.
|
||||
|
||||
Places an order on the stock market. This function only works for `Limit and Stop Orders <http://bitburner.wikia.com/wiki/Stock_Market#Order_Types>`_.
|
||||
|
||||
The ability to place limit and stop orders is **not** immediately available to the player and must be unlocked later on in the game.
|
||||
|
||||
Returns true if the order is successfully placed, and false otherwise.
|
||||
|
||||
cancelOrder
|
||||
-----------
|
||||
|
||||
.. js:function:: cancelOrder(sym, shares, price, type, pos)
|
||||
|
||||
: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
|
||||
:param string type: Type of order. It must specify "limit" or "stop", and must also specify "buy" or "sell". This is NOT
|
||||
case-sensitive. Here are four examples that will work:
|
||||
|
||||
* limitbuy
|
||||
* limitsell
|
||||
* stopbuy
|
||||
* stopsell
|
||||
|
||||
: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.
|
||||
|
||||
Cancels an oustanding Limit or Stop order on the stock market.
|
||||
|
||||
The ability to use limit and stop orders is **not** immediately available to the player and must be unlocked later on in the game.
|
||||
@@ -0,0 +1,42 @@
|
||||
Netscript Loops and Conditionals
|
||||
================================
|
||||
|
||||
|
||||
Loops and Conditionals
|
||||
----------------------
|
||||
|
||||
Netscript loops and conditionals are the same as Javascript. However, the one caveat is that when declaring variables such as the
|
||||
iterator for traversing a loop, you should not use the 'var' or 'let' keyword. For reference, you can see the Javascript
|
||||
documentation for loops/conditionals here:
|
||||
|
||||
`While loops <https://www.w3schools.com/js/js_loop_while.asp>`_
|
||||
|
||||
`For loops <https://www.w3schools.com/js/js_loop_for.asp>`_
|
||||
|
||||
`Conditionals (If/Else statements) <https://www.w3schools.com/js/js_if_else.asp>`_
|
||||
|
||||
Here are some simple code examples that show the use of loops and conditionals in Netscript.
|
||||
|
||||
The following is a while loop that runs the hack() Netscript function ten times::
|
||||
|
||||
i = 0;
|
||||
while (i < 10) {
|
||||
hack('foodnstuff');
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
The following is a for loop that runs the hack() Netscript function ten times::
|
||||
|
||||
for (i = 0; i < 10; ++i) {
|
||||
hack("foodnstuff");
|
||||
}
|
||||
|
||||
The following is a conditional that uses the getServerMoneyAvailable() Netscript function to check how much money
|
||||
exists on the 'foodnstuff' server. If there is more than $200,000 on the server, then the server will be hacked.
|
||||
Otherwise, the money available on the server will be grown using the grow() Netscript function::
|
||||
|
||||
if (getServerMoneyAvailable('foodnstuff') > 200000) {
|
||||
hack("foodnstuff");
|
||||
} else {
|
||||
grow("foodnstuff");
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
Netscript Operators
|
||||
===================
|
||||
|
||||
Operators
|
||||
---------
|
||||
|
||||
Binary Operators
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
Binary operators require two operands and produce a result based on their values. In general, binary
|
||||
operators do not change the value of the operands.
|
||||
|
||||
=========== =========================== ==============================================================
|
||||
Operator Name Example/Comments
|
||||
=========== =========================== ==============================================================
|
||||
= Assignment i = 5 would assign the value 5 to the variable i
|
||||
\+ Addition 5 + 12 would return 17
|
||||
\- Subtraction 20 - 8 would return 12
|
||||
\* Multiplication 4 * 5 would return 20
|
||||
\/ Division 50 / 10 would return 5
|
||||
% Modulo 50 % 9 would return 5
|
||||
&& Logical AND true && false would return false
|
||||
|| Logical OR true || false would return true
|
||||
< Less than 4 < 5 would return true
|
||||
> Greater than 4 > 5 would return false
|
||||
<= Less than or equal to 5 <= 5 would return true
|
||||
>= Greater than or equal to 5 >= 4 would return true
|
||||
== Equality 1 == 1 would return true
|
||||
!= Inequality 4 != 5 would return true
|
||||
=== Strict equality 1 === "1" would return false
|
||||
!== Strict inequality 1 !== "1" would return true
|
||||
=========== =========================== ==============================================================
|
||||
|
||||
Unary Operators
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Unary operators require only a single operand and produce a result based on their values. Some unary operators will
|
||||
change the value of their operands. For example::
|
||||
|
||||
i = 0;
|
||||
++i;
|
||||
|
||||
Running the pre-increment unary operator (++) in the code above changes the value of the variable i.
|
||||
|
||||
|
||||
=============== =========================== ==============================================================================================
|
||||
Operator Name Example/comments
|
||||
=============== =========================== ==============================================================================================
|
||||
! Logical NOT operator !true would return false, and !false would return true. Does not change operand's value
|
||||
\- Negation Negates a number. Only works for numerics. Does not change operand's value
|
||||
++ Pre-increment ++i or i++. WARNING: This only pre-increments, even if you put i++. Changes operand's value
|
||||
-- Pre-decrement --i or i--. WARNING: This only pre-decrements, even if you put i--. Changes operand's value
|
||||
=============== =========================== ==============================================================================================
|
||||
@@ -0,0 +1,17 @@
|
||||
Netscript Script Arguments
|
||||
==========================
|
||||
|
||||
Arguments passed into a script can be accessed in Netscript using a special array called *args*. The arguments can be
|
||||
accessed using a normal array using the [] operator (args[0], args[1], etc...).
|
||||
|
||||
For example, let's say we want to make a generic script 'generic-run.script' and we plan to pass two arguments into that script.
|
||||
The first argument will be the name of another script, and the second argument will be a number. This generic script will run the
|
||||
script specified in the first argument with the amount of threads specified in the second element. The code would look like::
|
||||
|
||||
run(args[0], args[1]);
|
||||
|
||||
It is also possible to get the number of arguments that was passed into a script using::
|
||||
|
||||
args.length
|
||||
|
||||
WARNING: Do not try to modify the args array. This will break the game. I will do my best to prevent players from doing this.
|
||||
@@ -0,0 +1,465 @@
|
||||
Netscript Singularity Functions
|
||||
===============================
|
||||
|
||||
The Singularity Functions are a special set of Netscript functions. These functions allow you to control
|
||||
many additional aspects of the game through scripts, such as working for factions/companies, purchasing/installing Augmentations,
|
||||
and creating programs.
|
||||
|
||||
The Singularity Functions are **not** immediately available to the player and must be unlocked later in the game.
|
||||
|
||||
**WARNING: This page contains spoilers for the game**.
|
||||
|
||||
The Singularity Functions are unlocked in BitNode-4. If you are in BitNode-4, then you will automatically have access to all of these functions.
|
||||
You can use the Singularity Functions in other BitNodes if and only if you have the Source-File for BitNode-4 (aka Source-File 4). Each level of
|
||||
Source-File 4 will open up additional Singularity Functions that you can use in other BitNodes. If your Source-File 4 is upgraded all the way to
|
||||
level 3, then you will be able to access all of the Singularity Functions.
|
||||
|
||||
Note that Singularity Functions require a lot of RAM outside of BitNode-4 (their RAM costs are multiplied by 10 if you are not in BitNode-4)
|
||||
|
||||
universityCourse
|
||||
----------------
|
||||
|
||||
.. js:function:: universityCourse(universityName, courseName)
|
||||
|
||||
:param string universityName:
|
||||
Name of university. Not case-sensitive. You must be in the correct city for whatever university you specify.
|
||||
|
||||
* Summit University
|
||||
* Rothman University
|
||||
* ZB Institute Of Technology
|
||||
:param string courseName:
|
||||
Name of course. Not case-sensitive.
|
||||
|
||||
* Study Computer Science
|
||||
* Data Strucures
|
||||
* Networks
|
||||
* Algorithms
|
||||
* Management
|
||||
* Leadership
|
||||
|
||||
If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.
|
||||
|
||||
This function will automatically set you to start taking a course at a university. If you are already in the middle of some
|
||||
"working" action (such as working at a company, for a faction, or on a program), then running this function will automatically
|
||||
cancel that action and give you your earnings.
|
||||
|
||||
The cost and experience gains for all of these universities and classes are the same as if you were to manually visit and take these classes.
|
||||
|
||||
This function will return true if you successfully start taking the course, and false otherwise.
|
||||
|
||||
gymWorkout
|
||||
----------
|
||||
|
||||
.. js:function:: gymWorkout(gymName, stat)
|
||||
|
||||
:param string gymName:
|
||||
Name of gym. Not case-sensitive. You must be in the correct city for whatever gym you specify.
|
||||
|
||||
* Crush Fitness Gym
|
||||
* Snap Fitness Gym
|
||||
* Iron Gym
|
||||
* Powerhouse Gym
|
||||
* Millenium Fitness Gym
|
||||
:param string stat:
|
||||
The stat you want to train. Not case-sensitive.
|
||||
|
||||
* strength OR str
|
||||
* defense OR def
|
||||
* dexterity OR dex
|
||||
* agility OR agi
|
||||
|
||||
If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.
|
||||
|
||||
This function will automatically set you to start working out at a gym to train a particular stat. If you are
|
||||
already in the middle of some "working" action (such as working at a company, for a faction, or on a program),
|
||||
then running this function will automatically cancel that action and give you your earnings.
|
||||
|
||||
The cost and experience gains for all of these gyms are the same as if you were to manually visit these gyms and train
|
||||
|
||||
This function will return true if you successfully start working out at the gym, and false otherwise.
|
||||
|
||||
travelToCity
|
||||
------------
|
||||
|
||||
.. js:function:: travelToCity(cityName)
|
||||
|
||||
:param string cityName:
|
||||
City to travel to. CASE-SENSITIVE.
|
||||
|
||||
* Aevum
|
||||
* Chongqing
|
||||
* Sector-12
|
||||
* New Tokyo
|
||||
* Ishima
|
||||
* Volhaven
|
||||
|
||||
If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.
|
||||
|
||||
This function allows the player to travel to any city. The cost for using this function is the same as the cost for traveling through the Travel Agency.
|
||||
|
||||
This function will return true if you successfully travel to the specified city and false otherwise.
|
||||
|
||||
purchaseTor
|
||||
-----------
|
||||
|
||||
.. js:function:: purchaseTor()
|
||||
|
||||
If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.
|
||||
|
||||
This function allows you to automatically purchase a TOR router. The cost for purchasing a TOR router using this
|
||||
function is the same as if you were to manually purchase one.
|
||||
|
||||
This function will return true if it successfully purchase a TOR router and false otherwise.
|
||||
|
||||
purchaseProgram
|
||||
---------------
|
||||
|
||||
.. js:function:: purchaseProgram(programName)
|
||||
|
||||
:param string programName: Name of program to purchase. Must include '.exe' extension. Not case-sensitive.
|
||||
|
||||
If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.
|
||||
|
||||
This function allows you to automatically purchase programs. You MUST have a TOR router in order to use this function.
|
||||
The cost of purchasing programs using this function is the same as if you were purchasing them through the Dark Web using the
|
||||
Terminal *buy* command.
|
||||
|
||||
Example::
|
||||
|
||||
purchaseProgram("brutessh.exe");
|
||||
|
||||
This function will return true if the specified program is purchased, and false otherwise.
|
||||
|
||||
getStats
|
||||
--------
|
||||
|
||||
.. js:function:: getStats()
|
||||
|
||||
If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to run this function.
|
||||
|
||||
Returns an object with the Player's stats. The object has the following properties::
|
||||
|
||||
Player.hacking
|
||||
Player.strength
|
||||
Player.defense
|
||||
Player.dexterity
|
||||
Player.agility
|
||||
Player.charisma
|
||||
Player.intelligence
|
||||
|
||||
Example::
|
||||
|
||||
res = getStats();
|
||||
print('My charisma level is: ' + res.charisma);
|
||||
|
||||
isBusy
|
||||
------
|
||||
|
||||
.. js:function:: isBusy()
|
||||
|
||||
If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to run this function.
|
||||
|
||||
Returns a boolean indicating whether or not the player is currently performing an 'action'. These actions include
|
||||
working for a company/faction, studying at a univeristy, working out at a gym, creating a program, or committing a crime.
|
||||
|
||||
upgradeHomeRam
|
||||
--------------
|
||||
|
||||
.. js:function:: upgradeHomeRam()
|
||||
|
||||
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 upgrade amount of RAM on the player's home computer. The cost is the same as if you were to do it manually.
|
||||
|
||||
This function will return true if the player's home computer RAM is successfully upgraded, and false otherwise.
|
||||
|
||||
getUpgradeHomeRamCost
|
||||
---------------------
|
||||
|
||||
.. js:function:: getUpgradeHomeRamCost()
|
||||
|
||||
If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.
|
||||
|
||||
Returns the cost of upgrading the player's home computer RAM.
|
||||
|
||||
workForCompany
|
||||
--------------
|
||||
|
||||
.. js:function:: workForCompany()
|
||||
|
||||
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 set you to start working at the company at which you are employed.
|
||||
If you are already in the middle of some "working" action (such as working for a faction, training at
|
||||
a gym, or creating a program), then running this function will automatically cancel that action and give you your earnings.
|
||||
|
||||
This function will return true if the player starts working, and false otherwise.
|
||||
|
||||
Note that when you are working for a company, you will not actually receive your earnings
|
||||
(reputation, money, experience) until you FINISH the action. This can be an issue if, for example,
|
||||
you only want to work until you get 100,000 company reputation. One small hack to get around this is to
|
||||
continuously restart the action to receive your earnings::
|
||||
|
||||
while (getCompanyRep(COMPANY HERE) < VALUE) {
|
||||
workForCompany();
|
||||
sleep(60000);
|
||||
}
|
||||
|
||||
This way, your company reputation will be updated every minute.
|
||||
|
||||
applyToCompany
|
||||
--------------
|
||||
|
||||
.. js:function:: applyToCompany(companyName, field)
|
||||
|
||||
:param string companyName: Name of company to apply to. CASE-SENSITIVE.
|
||||
:param string field:
|
||||
Field to which you want to apply. Not case-sensitive
|
||||
|
||||
* software
|
||||
* software consultant
|
||||
* it
|
||||
* security engineer
|
||||
* network engineer
|
||||
* business
|
||||
* business consultant
|
||||
* security
|
||||
* agent
|
||||
* employee
|
||||
* part-time employee
|
||||
* waiter
|
||||
* part-time waiter
|
||||
|
||||
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.
|
||||
|
||||
getCompanyRep
|
||||
-------------
|
||||
|
||||
.. js:function:: getCompanyRep(companyName)
|
||||
|
||||
:param string companyName: Name of the company. CASE-SENSITIVE
|
||||
|
||||
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 return the amount of reputation you have at the specified company.
|
||||
If the company passed in as an argument is invalid, -1 will be returned.
|
||||
|
||||
checkFactionInvitations
|
||||
-----------------------
|
||||
|
||||
.. js:function:: checkFactionInvitations()
|
||||
|
||||
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.
|
||||
|
||||
joinFaction
|
||||
-----------
|
||||
|
||||
.. js:function:: joinFaction(name)
|
||||
|
||||
:param string name: Name of faction to join. CASE-SENSITIVE
|
||||
|
||||
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 accept an invitation from a faction and join it.
|
||||
|
||||
workForFaction
|
||||
--------------
|
||||
|
||||
.. js:function:: workForFaction(factionName, workType)
|
||||
|
||||
:param string factionName: Name of faction to work for. CASE-SENSITIVE
|
||||
:param string workType:
|
||||
Type of work to perform for the faction
|
||||
|
||||
* hacking/hacking contracts/hackingcontracts
|
||||
* field/fieldwork/field work
|
||||
* security/securitywork/security work
|
||||
|
||||
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 set you to start working for the specified faction.
|
||||
Obviously, you must be a member of the faction or else this function will fail. If you are already in
|
||||
the middle of some "working" action (such as working for a company, training at a gym, or creating a program),
|
||||
then running this function will automatically cancel that action and give you your earnings.
|
||||
|
||||
This function will return true if you successfully start working for the specified faction, and false otherwise.
|
||||
|
||||
Note that when you are working for a faction, you will not actually receive your earnings (reputation, experience)
|
||||
until you FINISH the action. This can be an issue if, for example, you only want to work until you get 100,000 faction
|
||||
reputation. One small hack to get around this is to continuously restart the action to receive your earnings::
|
||||
|
||||
while (getFactionRep(FACTION NAME) < VALUE) {
|
||||
workForFaction(FACNAME, WORKTYPE);
|
||||
sleep(60000);
|
||||
}
|
||||
|
||||
This way, your faction reputation will be updated every minute.
|
||||
|
||||
getFactionRep
|
||||
-------------
|
||||
|
||||
.. js:function:: getFactionRep(factionName)
|
||||
|
||||
:param string factionName: Name of faction. CASE-SENSITIVE
|
||||
|
||||
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 returns the amount of reputation you have for the specified faction.
|
||||
|
||||
createProgram
|
||||
-------------
|
||||
|
||||
.. js:function:: createProgram(programName)
|
||||
|
||||
:param string programName: Name of program to create. Not 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 will automatically set you to start working on creating the specified program. If you are
|
||||
already in the middle of some "working" action (such as working for a company, training at a gym, or taking a course),
|
||||
then running this function will automatically cancel that action and give you your earnings.
|
||||
|
||||
Example:
|
||||
|
||||
createProgram("relaysmtp.exe");
|
||||
|
||||
Note that creating a program using this function has the same hacking level requirements as it normally would. These level requirements are:
|
||||
|
||||
* BruteSSH.exe: 50
|
||||
* FTPCrack.exe: 100
|
||||
* relaySMTP.exe: 250
|
||||
* HTTPWorm.exe: 500
|
||||
* SQLInject.exe: 750
|
||||
* DeepscanV1.exe: 75
|
||||
* 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.
|
||||
|
||||
commitCrime
|
||||
-----------
|
||||
|
||||
.. js:function::commitCrime(crime)
|
||||
|
||||
: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:
|
||||
|
||||
* shoplift
|
||||
* rob store
|
||||
* mug
|
||||
* larceny
|
||||
* deal drugs
|
||||
* bond forgery
|
||||
* traffick arms
|
||||
* homicide
|
||||
* grand theft auto
|
||||
* kidnap
|
||||
* assassinate
|
||||
* heist
|
||||
|
||||
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 is used to automatically attempt to commit crimes. If you are already in the middle of some 'working' action
|
||||
(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.
|
||||
|
||||
Note that crimes committed using this function will have all of their earnings halved (this applied for both money and experience!)
|
||||
|
||||
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).
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
getCrimeChance
|
||||
--------------
|
||||
|
||||
.. js:function:: getCrimeChance(crime)
|
||||
|
||||
:param string crime:
|
||||
Name of crime. Not case-sensitive. This argument is fairlyn lenient in terms of what inputs it accepts.
|
||||
Check the documentation for the *commitCrime()* function for a list of example inputs.
|
||||
|
||||
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 your chance of success at commiting the specified crime. The chance is returned as a decimal (i.e. 60% would be returned as 0.6).
|
||||
|
||||
getOwnedAugmentations
|
||||
---------------------
|
||||
|
||||
.. js:function:: getOwnedAugmentations(purchased=false)
|
||||
|
||||
:param boolean purchase:
|
||||
Specifies whether the returned array should include Augmentations you have purchased but not yet installed.
|
||||
By default, this argument is false which means that the return value will NOT have the purchased Augmentations.
|
||||
|
||||
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 containing the names (as strings) of all Augmentations you have.
|
||||
|
||||
getAugmentationsFromFaction
|
||||
---------------------------
|
||||
|
||||
.. js:function:: getAugmentationsFromFaction(facName)
|
||||
|
||||
:param string facName: Name of faction. 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.
|
||||
|
||||
Returns an array containing the names (as strings) of all Augmentations that are available from the specified faction.
|
||||
|
||||
getAugmentationCost
|
||||
-------------------
|
||||
|
||||
.. js:function:: getAugmentationCost(augName)
|
||||
|
||||
: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].
|
||||
|
||||
purchaseAugmentation
|
||||
--------------------
|
||||
|
||||
.. js:function:: purchaseAugmentation(factionName, augName)
|
||||
|
||||
:param string factionName: Name of faction to purchase Augmentation from. CASE-SENSITIVE
|
||||
:param string augName: Name of Augmentation to purchase. 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 will try to purchase the specified Augmentation through the given Faction.
|
||||
|
||||
This function will return true if the Augmentation is successfully purchased, and false otherwise.
|
||||
|
||||
installAugmentations
|
||||
--------------------
|
||||
|
||||
.. js:function:: installAugmentations(cbScript)
|
||||
|
||||
:param string cbScript:
|
||||
Optional callback script. This is a script that will automatically be run after Augmentations are installed (after the reset).
|
||||
This script will be run with no arguments and 1 thread. It must be located on your home computer.
|
||||
|
||||
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 will automatically install your Augmentations, resetting the game as usual.
|
||||
|
||||
It will return true if successful, and false otherwise.
|
||||
Reference in New Issue
Block a user