v0.34.5. Also adding webpack config and package-lock.json

This commit is contained in:
danielyxie 2018-02-24 16:55:06 -06:00
parent 85ccb294dd
commit 779ce25ae5
49 changed files with 5537 additions and 1475 deletions

@ -1,7 +1,7 @@
#cmpy-mgmt-container p, #cmpy-mgmt-container p,
#cmpy-mgmt-container a, #cmpy-mgmt-container a,
#cmpy-mgmt-container div { #cmpy-mgmt-container div {
font-size: 14px; font-size: 13px;
} }
@ -123,9 +123,10 @@
.cmpy-mgmt-upgrade-div { .cmpy-mgmt-upgrade-div {
display:inline-block; display:inline-block;
border:1px solid white; border:1px solid white;
margin:4px; margin:2px;
padding:12px; padding:6px;
border-radius:25px; border-radius:25px;
font-size:"12px";
color:var(--my-font-color); color:var(--my-font-color);
} }

@ -222,8 +222,26 @@ a:link, a:visited {
z-index: 99; z-index: 99;
} }
/* Similar to a normal tooltip except its positioned on the left of the elemnt
rather than the right to avoid exceeding the elements normal width */
.tooltip .tooltiptextleft {
visibility: hidden;
width: 300px;
background-color: var(--my-background-color);
border: 2px solid var(--my-highlight-color);;
color: white;
text-align: center;
padding: 4px;
left: 40%;
bottom:-10%;
position: absolute;
z-index: 99;
}
.tooltip:hover .tooltiptext, .tooltip:hover .tooltiptext,
.tooltip:hover .tooltiptexthigh { .tooltip:hover .tooltiptexthigh,
.tooltip:hover .tooltiptextleft {
visibility: visible; visibility: visible;
} }

2353
dist/bundle.js vendored

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
doc/build/doctrees/netscriptmisc.doctree vendored Normal file

Binary file not shown.

@ -23,3 +23,4 @@ to reach out to the developer!
Hacknet Node API <netscripthacknetnodeapi> Hacknet Node API <netscripthacknetnodeapi>
Trade Information eXchange (TIX) API <netscriptixapi> Trade Information eXchange (TIX) API <netscriptixapi>
Singularity Functions <netscriptsingularityfunctions> Singularity Functions <netscriptsingularityfunctions>
Miscellaneous <netscriptmisc>

@ -12,7 +12,7 @@ hack
.. js:function:: hack(hostname/ip) .. js:function:: hack(hostname/ip)
:param string hostname/ip: IP or hostname of the target server to hack :param string hostname/ip: IP or hostname of the target server to hack
:returns: True if the hack is successful, false otherwise :returns: The amount of money stolen if the hack is successful, and zero otherwise
Function that is used to try and hack servers to steal money and gain hacking experience. The runtime for this command depends 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 on your hacking level and the target server's security level. In order to hack a server you must first gain root access
@ -72,10 +72,9 @@ weaken
sleep sleep
^^^^^ ^^^^^
.. js:function:: sleep(n[, log=true]) .. js:function:: sleep(n)
:param number n: Number of milliseconds to sleep :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. Suspends the script for n milliseconds.
@ -97,6 +96,39 @@ tprint
Prints a value or a variable to the Terminal Prints a value or a variable to the Terminal
clearLog
^^^^^^^^
.. js:function:: clearLog()
Clears the script's logs
disableLog
^^^^^^^^^^
.. js:function:: disableLog(fn)
:param string fn: 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.
Notable functions that cannot have their logs disabled: run, exec, exit
enableLog
^^^^^^^^^
.. js:function:: enableLog(fn)
:param string fn: 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')
scan scan
^^^^ ^^^^
@ -304,7 +336,8 @@ killall
:param string hostname/ip: IP or hostname of the server on which to kill all scripts :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. 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.
exit exit
@ -346,9 +379,10 @@ scp
ls ls
^^ ^^
.. js:function:: ls(hostname/ip) .. js:function:: ls(hostname/ip, [grep])
:param string hostname/ip: Hostname or IP of the target server :param string hostname/ip: Hostname or IP of the target server
:param string grep: a substring to search for in the filename
Returns an array with the filenames of all files on the specified server (as strings). The returned array Returns an array with the filenames of all files on the specified server (as strings). The returned array
is sorted in alphabetic order is sorted in alphabetic order
@ -639,15 +673,6 @@ getPurchasedServers
Returns an array with either the hostnames or IPs 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.
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 write
^^^^^ ^^^^^
@ -684,6 +709,18 @@ read
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 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. the text file does not exist, an empty string will be returned.
peek
^^^^
.. js:function:: peek(port)
:param number port: Port to peek. Must be an integer between 1 and 10
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 `Netscript Ports work here <http://bitburner.wikia.com/wiki/Netscript_Ports>`_.
clear clear
^^^^^ ^^^^^
@ -697,6 +734,16 @@ clear
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 *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.
rm
^^
.. js:function:: rm(fn)
:param string fn: Filename of file to remove. Must include the extension
:returns: True if it successfully deletes the file, and false otherwise
Removes the specified file from the current server. This function works for every file type except message (.msg) files.
scriptRunning scriptRunning
^^^^^^^^^^^^^ ^^^^^^^^^^^^^

@ -2,9 +2,6 @@ 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 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 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: documentation for loops/conditionals here:

@ -0,0 +1,37 @@
Netscript Miscellaneous
=======================
Comments
--------
Netscript supports comments using the same syntax as `Javascript comments <https://www.w3schools.com/js/js_comments.asp>`_.
Comments are not evaluated as code, and can be used to document and/or explain code::
//This is a comment and will not get executed even though its in the code
/* Multi
* line
* comment */
print("This code will actually get executed");
Javascript Math Module
----------------------
The `Javascript Math Module <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math>`_ is
supported in Netscript and is used in the same way::
numThreads = Math.floor(getServerRam("foodnstuff")[1] / 3.4);
Javascript Date Module
----------------------
The `Javascript Date Module <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date>`_ is supported in Netscript.
However, since the 'new' operator does not work in Netscript, only the Date module's static functions can be used:
* now()
* UTC()
* Parse()
* Maybe some others I don't know about
Example::
time = Date.now();

@ -102,6 +102,8 @@
</ul></td> </ul></td>
<td style="width: 33%; vertical-align: top;"><ul> <td style="width: 33%; vertical-align: top;"><ul>
<li><a href="netscriptfunctions.html#clear">clear() (built-in function)</a> <li><a href="netscriptfunctions.html#clear">clear() (built-in function)</a>
</li>
<li><a href="netscriptfunctions.html#clearLog">clearLog() (built-in function)</a>
</li> </li>
<li><a href="netscriptsingularityfunctions.html#createProgram">createProgram() (built-in function)</a> <li><a href="netscriptsingularityfunctions.html#createProgram">createProgram() (built-in function)</a>
</li> </li>
@ -112,6 +114,10 @@
<table style="width: 100%" class="indextable genindextable"><tr> <table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul> <td style="width: 33%; vertical-align: top;"><ul>
<li><a href="netscriptfunctions.html#deleteServer">deleteServer() (built-in function)</a> <li><a href="netscriptfunctions.html#deleteServer">deleteServer() (built-in function)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="netscriptfunctions.html#disableLog">disableLog() (built-in function)</a>
</li> </li>
</ul></td> </ul></td>
</tr></table> </tr></table>
@ -119,10 +125,12 @@
<h2 id="E">E</h2> <h2 id="E">E</h2>
<table style="width: 100%" class="indextable genindextable"><tr> <table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul> <td style="width: 33%; vertical-align: top;"><ul>
<li><a href="netscriptfunctions.html#exec">exec() (built-in function)</a> <li><a href="netscriptfunctions.html#enableLog">enableLog() (built-in function)</a>
</li> </li>
</ul></td> </ul></td>
<td style="width: 33%; vertical-align: top;"><ul> <td style="width: 33%; vertical-align: top;"><ul>
<li><a href="netscriptfunctions.html#exec">exec() (built-in function)</a>
</li>
<li><a href="netscriptfunctions.html#exit">exit() (built-in function)</a> <li><a href="netscriptfunctions.html#exit">exit() (built-in function)</a>
</li> </li>
</ul></td> </ul></td>
@ -317,16 +325,18 @@
<h2 id="P">P</h2> <h2 id="P">P</h2>
<table style="width: 100%" class="indextable genindextable"><tr> <table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul> <td style="width: 33%; vertical-align: top;"><ul>
<li><a href="netscriptfunctions.html#peek">peek() (built-in function)</a>
</li>
<li><a href="netscriptixapi.html#placeOrder">placeOrder() (built-in function)</a> <li><a href="netscriptixapi.html#placeOrder">placeOrder() (built-in function)</a>
</li> </li>
<li><a href="netscriptfunctions.html#print">print() (built-in function)</a> <li><a href="netscriptfunctions.html#print">print() (built-in function)</a>
</li> </li>
<li><a href="netscriptfunctions.html#prompt">prompt() (built-in function)</a> <li><a href="netscriptfunctions.html#prompt">prompt() (built-in function)</a>
</li>
<li><a href="netscriptsingularityfunctions.html#purchaseAugmentation">purchaseAugmentation() (built-in function)</a>
</li> </li>
</ul></td> </ul></td>
<td style="width: 33%; vertical-align: top;"><ul> <td style="width: 33%; vertical-align: top;"><ul>
<li><a href="netscriptsingularityfunctions.html#purchaseAugmentation">purchaseAugmentation() (built-in function)</a>
</li>
<li><a href="netscriptfunctions.html#purchaseHacknetNode">purchaseHacknetNode() (built-in function)</a> <li><a href="netscriptfunctions.html#purchaseHacknetNode">purchaseHacknetNode() (built-in function)</a>
</li> </li>
<li><a href="netscriptsingularityfunctions.html#purchaseProgram">purchaseProgram() (built-in function)</a> <li><a href="netscriptsingularityfunctions.html#purchaseProgram">purchaseProgram() (built-in function)</a>
@ -347,7 +357,7 @@
</li> </li>
</ul></td> </ul></td>
<td style="width: 33%; vertical-align: top;"><ul> <td style="width: 33%; vertical-align: top;"><ul>
<li><a href="netscriptfunctions.html#round">round() (built-in function)</a> <li><a href="netscriptfunctions.html#rm">rm() (built-in function)</a>
</li> </li>
<li><a href="netscriptfunctions.html#run">run() (built-in function)</a> <li><a href="netscriptfunctions.html#run">run() (built-in function)</a>
</li> </li>

@ -75,10 +75,7 @@ secrets that you've been searching for.</p>
</li> </li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="netscriptloopsandconditionals.html"> Loops and Conditionals</a><ul> <li class="toctree-l2"><a class="reference internal" href="netscriptloopsandconditionals.html"> Loops and Conditionals</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptloopsandconditionals.html#loops-and-conditionals">Loops and Conditionals</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="netscriptscriptarguments.html"> Script Arguments</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptscriptarguments.html"> Script Arguments</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html"> Basic Functions</a><ul> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html"> Basic Functions</a><ul>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#hack">hack</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#hack">hack</a></li>
@ -87,6 +84,9 @@ secrets that you've been searching for.</p>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#sleep">sleep</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#sleep">sleep</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#print">print</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#print">print</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#tprint">tprint</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#tprint">tprint</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#clearlog">clearLog</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#disablelog">disableLog</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#enablelog">enableLog</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#scan">scan</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#scan">scan</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#nuke">nuke</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#nuke">nuke</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#brutessh">brutessh</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#brutessh">brutessh</a></li>
@ -123,10 +123,11 @@ secrets that you've been searching for.</p>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#purchaseserver">purchaseServer</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#purchaseserver">purchaseServer</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#deleteserver">deleteServer</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#deleteserver">deleteServer</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#getpurchasedservers">getPurchasedServers</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#getpurchasedservers">getPurchasedServers</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#round">round</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#write">write</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#write">write</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#read">read</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#read">read</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#peek">peek</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#clear">clear</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#clear">clear</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#rm">rm</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#scriptrunning">scriptRunning</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#scriptrunning">scriptRunning</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#scriptkill">scriptKill</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#scriptkill">scriptKill</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#getscriptram">getScriptRam</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#getscriptram">getScriptRam</a></li>
@ -194,6 +195,12 @@ secrets that you've been searching for.</p>
<li class="toctree-l3"><a class="reference internal" href="netscriptsingularityfunctions.html#installaugmentations">installAugmentations</a></li> <li class="toctree-l3"><a class="reference internal" href="netscriptsingularityfunctions.html#installaugmentations">installAugmentations</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a><ul>
<li class="toctree-l3"><a class="reference internal" href="netscriptmisc.html#comments">Comments</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptmisc.html#javascript-math-module">Javascript Math Module</a></li>
<li class="toctree-l3"><a class="reference internal" href="netscriptmisc.html#javascript-date-module">Javascript Date Module</a></li>
</ul>
</li>
</ul> </ul>
</li> </li>
</ul> </ul>

@ -76,10 +76,7 @@ to reach out to the developer!</p>
</li> </li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="netscriptloopsandconditionals.html"> Loops and Conditionals</a><ul> <li class="toctree-l1"><a class="reference internal" href="netscriptloopsandconditionals.html"> Loops and Conditionals</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptloopsandconditionals.html#loops-and-conditionals">Loops and Conditionals</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="netscriptscriptarguments.html"> Script Arguments</a></li> <li class="toctree-l1"><a class="reference internal" href="netscriptscriptarguments.html"> Script Arguments</a></li>
<li class="toctree-l1"><a class="reference internal" href="netscriptfunctions.html"> Basic Functions</a><ul> <li class="toctree-l1"><a class="reference internal" href="netscriptfunctions.html"> Basic Functions</a><ul>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#hack">hack</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#hack">hack</a></li>
@ -88,6 +85,9 @@ to reach out to the developer!</p>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#sleep">sleep</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#sleep">sleep</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#print">print</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#print">print</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#tprint">tprint</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#tprint">tprint</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#clearlog">clearLog</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#disablelog">disableLog</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#enablelog">enableLog</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#scan">scan</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#scan">scan</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#nuke">nuke</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#nuke">nuke</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#brutessh">brutessh</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#brutessh">brutessh</a></li>
@ -124,10 +124,11 @@ to reach out to the developer!</p>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#purchaseserver">purchaseServer</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#purchaseserver">purchaseServer</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#deleteserver">deleteServer</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#deleteserver">deleteServer</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#getpurchasedservers">getPurchasedServers</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#getpurchasedservers">getPurchasedServers</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#round">round</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#write">write</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#write">write</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#read">read</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#read">read</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#peek">peek</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#clear">clear</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#clear">clear</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#rm">rm</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#scriptrunning">scriptRunning</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#scriptrunning">scriptRunning</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#scriptkill">scriptKill</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#scriptkill">scriptKill</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#getscriptram">getScriptRam</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#getscriptram">getScriptRam</a></li>
@ -195,6 +196,12 @@ to reach out to the developer!</p>
<li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html#installaugmentations">installAugmentations</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html#installaugmentations">installAugmentations</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a><ul>
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html#comments">Comments</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html#javascript-math-module">Javascript Math Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html#javascript-date-module">Javascript Date Module</a></li>
</ul>
</li>
</ul> </ul>
</div> </div>
</div> </div>
@ -218,6 +225,7 @@ to reach out to the developer!</p>
<li class="toctree-l2"><a class="reference internal" href="netscripthacknetnodeapi.html"> Hacknet Node API</a></li> <li class="toctree-l2"><a class="reference internal" href="netscripthacknetnodeapi.html"> Hacknet Node API</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptixapi.html"> Trade Information eXchange (TIX) API</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptixapi.html"> Trade Information eXchange (TIX) API</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html"> Singularity Functions</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html"> Singularity Functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>

@ -70,7 +70,7 @@ This includes information such as function signatures, what they do, and their r
</ul> </ul>
</td> </td>
</tr> </tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">True if the hack is successful, false otherwise</p> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">The amount of money stolen if the hack is successful, and zero otherwise</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -158,14 +158,13 @@ root access to the target server, but there is no required hacking level to run
<h2>sleep<a class="headerlink" href="#sleep" title="Permalink to this headline"></a></h2> <h2>sleep<a class="headerlink" href="#sleep" title="Permalink to this headline"></a></h2>
<dl class="function"> <dl class="function">
<dt> <dt>
<code class="descname">sleep</code><span class="sig-paren">(</span><em>n</em><span class="optional">[</span>, <em>log=true</em><span class="optional">]</span><span class="sig-paren">)</span></dt> <code class="descname">sleep</code><span class="sig-paren">(</span><em>n</em><span class="sig-paren">)</span></dt>
<dd><table class="docutils field-list" frame="void" rules="none"> <dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" /> <col class="field-name" />
<col class="field-body" /> <col class="field-body" />
<tbody valign="top"> <tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple"> <tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>n</strong> (<em>number</em>) -- Number of milliseconds to sleep</li> <li><strong>n</strong> (<em>number</em>) -- Number of milliseconds to sleep</li>
<li><strong>log</strong> (<em>boolean</em>) -- Optional boolean specifying whether or not to log the action</li>
</ul> </ul>
</td> </td>
</tr> </tr>
@ -214,6 +213,61 @@ root access to the target server, but there is no required hacking level to run
<p>Prints a value or a variable to the Terminal</p> <p>Prints a value or a variable to the Terminal</p>
</dd></dl> </dd></dl>
</div>
<div class="section" id="clearlog">
<h2>clearLog<a class="headerlink" href="#clearlog" title="Permalink to this headline"></a></h2>
<dl class="function">
<dt id="clearLog">
<code class="descname">clearLog</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#clearLog" title="Permalink to this definition"></a></dt>
<dd><p>Clears the script's logs</p>
</dd></dl>
</div>
<div class="section" id="disablelog">
<h2>disableLog<a class="headerlink" href="#disablelog" title="Permalink to this headline"></a></h2>
<dl class="function">
<dt id="disableLog">
<code class="descname">disableLog</code><span class="sig-paren">(</span><em>fn</em><span class="sig-paren">)</span><a class="headerlink" href="#disableLog" title="Permalink to this definition"></a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>fn</strong> (<em>string</em>) -- Name of function for which to disable logging</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Disables logging for the given function. Logging can be disabled for
all functions by passing 'ALL' as the argument.</p>
<p>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.</p>
<p>Notable functions that cannot have their logs disabled: run, exec, exit</p>
</dd></dl>
</div>
<div class="section" id="enablelog">
<h2>enableLog<a class="headerlink" href="#enablelog" title="Permalink to this headline"></a></h2>
<dl class="function">
<dt id="enableLog">
<code class="descname">enableLog</code><span class="sig-paren">(</span><em>fn</em><span class="sig-paren">)</span><a class="headerlink" href="#enableLog" title="Permalink to this definition"></a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>fn</strong> (<em>string</em>) -- Name of function for which to enable logging</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>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')</p>
</dd></dl>
</div> </div>
<div class="section" id="scan"> <div class="section" id="scan">
<h2>scan<a class="headerlink" href="#scan" title="Permalink to this headline"></a></h2> <h2>scan<a class="headerlink" href="#scan" title="Permalink to this headline"></a></h2>
@ -544,7 +598,8 @@ is not the same as <em>foo.script</em> run with the argument 2, even though they
</tr> </tr>
</tbody> </tbody>
</table> </table>
<p>Kills all running scripts on the specified server. This function will always return true.</p> <p>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.</p>
</dd></dl> </dd></dl>
</div> </div>
@ -599,13 +654,14 @@ then this function will return true if at least one of the files in the array is
<h2>ls<a class="headerlink" href="#ls" title="Permalink to this headline"></a></h2> <h2>ls<a class="headerlink" href="#ls" title="Permalink to this headline"></a></h2>
<dl class="function"> <dl class="function">
<dt> <dt>
<code class="descname">ls</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span></dt> <code class="descname">ls</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="optional">[</span>, <em>grep</em><span class="optional">]</span><span class="sig-paren">)</span></dt>
<dd><table class="docutils field-list" frame="void" rules="none"> <dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" /> <col class="field-name" />
<col class="field-body" /> <col class="field-body" />
<tbody valign="top"> <tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple"> <tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of the target server</li> <li><strong>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of the target server</li>
<li><strong>grep</strong> (<em>string</em>) -- a substring to search for in the filename</li>
</ul> </ul>
</td> </td>
</tr> </tr>
@ -1078,26 +1134,6 @@ then IPs will be returned. If this argument is omitted then it is true by defaul
<p>Returns an array with either the hostnames or IPs of all of the servers you have purchased.</p> <p>Returns an array with either the hostnames or IPs of all of the servers you have purchased.</p>
</dd></dl> </dd></dl>
</div>
<div class="section" id="round">
<h2>round<a class="headerlink" href="#round" title="Permalink to this headline"></a></h2>
<dl class="function">
<dt>
<code class="descname">round</code><span class="sig-paren">(</span><em>n</em><span class="sig-paren">)</span></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>n</strong> (<em>number</em>) -- Number to round</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Returns the argument <em>n</em> rounded to the nearest integer. If the argument passed in is not a number, then the function will return 0.</p>
</dd></dl>
</div> </div>
<div class="section" id="write"> <div class="section" id="write">
<h2>write<a class="headerlink" href="#write" title="Permalink to this headline"></a></h2> <h2>write<a class="headerlink" href="#write" title="Permalink to this headline"></a></h2>
@ -1152,6 +1188,28 @@ will remove the first element from that queue and return it. If the queue is emp
the text file does not exist, an empty string will be returned.</p> the text file does not exist, an empty string will be returned.</p>
</dd></dl> </dd></dl>
</div>
<div class="section" id="peek">
<h2>peek<a class="headerlink" href="#peek" title="Permalink to this headline"></a></h2>
<dl class="function">
<dt>
<code class="descname">peek</code><span class="sig-paren">(</span><em>port</em><span class="sig-paren">)</span></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
<li><strong>port</strong> (<em>number</em>) -- Port to peek. Must be an integer between 1 and 10</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>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 &quot;NULL PORT DATA&quot; will be returned.</p>
<p>Read about how <a class="reference external" href="http://bitburner.wikia.com/wiki/Netscript_Ports">Netscript Ports work here</a>.</p>
</dd></dl>
</div> </div>
<div class="section" id="clear"> <div class="section" id="clear">
<h2>clear<a class="headerlink" href="#clear" title="Permalink to this headline"></a></h2> <h2>clear<a class="headerlink" href="#clear" title="Permalink to this headline"></a></h2>
@ -1174,6 +1232,29 @@ the text file does not exist, an empty string will be returned.</p>
<p>If the <em>port/fn</em> argument is a string, then it specifies the name of a text file (.txt) and will delete all data from that text file.</p> <p>If the <em>port/fn</em> argument is a string, then it specifies the name of a text file (.txt) and will delete all data from that text file.</p>
</dd></dl> </dd></dl>
</div>
<div class="section" id="rm">
<h2>rm<a class="headerlink" href="#rm" title="Permalink to this headline"></a></h2>
<dl class="function">
<dt>
<code class="descname">rm</code><span class="sig-paren">(</span><em>fn</em><span class="sig-paren">)</span></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
<li><strong>fn</strong> (<em>string</em>) -- Filename of file to remove. Must include the extension</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">True if it successfully deletes the file, and false otherwise</p>
</td>
</tr>
</tbody>
</table>
<p>Removes the specified file from the current server. This function works for every file type except message (.msg) files.</p>
</dd></dl>
</div> </div>
<div class="section" id="scriptrunning"> <div class="section" id="scriptrunning">
<h2>scriptRunning<a class="headerlink" href="#scriptrunning" title="Permalink to this headline"></a></h2> <h2>scriptRunning<a class="headerlink" href="#scriptrunning" title="Permalink to this headline"></a></h2>
@ -1505,6 +1586,9 @@ you create in functions such as <a class="reference external" href="https://deve
<li class="toctree-l3"><a class="reference internal" href="#sleep">sleep</a></li> <li class="toctree-l3"><a class="reference internal" href="#sleep">sleep</a></li>
<li class="toctree-l3"><a class="reference internal" href="#print">print</a></li> <li class="toctree-l3"><a class="reference internal" href="#print">print</a></li>
<li class="toctree-l3"><a class="reference internal" href="#tprint">tprint</a></li> <li class="toctree-l3"><a class="reference internal" href="#tprint">tprint</a></li>
<li class="toctree-l3"><a class="reference internal" href="#clearlog">clearLog</a></li>
<li class="toctree-l3"><a class="reference internal" href="#disablelog">disableLog</a></li>
<li class="toctree-l3"><a class="reference internal" href="#enablelog">enableLog</a></li>
<li class="toctree-l3"><a class="reference internal" href="#scan">scan</a></li> <li class="toctree-l3"><a class="reference internal" href="#scan">scan</a></li>
<li class="toctree-l3"><a class="reference internal" href="#nuke">nuke</a></li> <li class="toctree-l3"><a class="reference internal" href="#nuke">nuke</a></li>
<li class="toctree-l3"><a class="reference internal" href="#brutessh">brutessh</a></li> <li class="toctree-l3"><a class="reference internal" href="#brutessh">brutessh</a></li>
@ -1541,10 +1625,11 @@ you create in functions such as <a class="reference external" href="https://deve
<li class="toctree-l3"><a class="reference internal" href="#purchaseserver">purchaseServer</a></li> <li class="toctree-l3"><a class="reference internal" href="#purchaseserver">purchaseServer</a></li>
<li class="toctree-l3"><a class="reference internal" href="#deleteserver">deleteServer</a></li> <li class="toctree-l3"><a class="reference internal" href="#deleteserver">deleteServer</a></li>
<li class="toctree-l3"><a class="reference internal" href="#getpurchasedservers">getPurchasedServers</a></li> <li class="toctree-l3"><a class="reference internal" href="#getpurchasedservers">getPurchasedServers</a></li>
<li class="toctree-l3"><a class="reference internal" href="#round">round</a></li>
<li class="toctree-l3"><a class="reference internal" href="#write">write</a></li> <li class="toctree-l3"><a class="reference internal" href="#write">write</a></li>
<li class="toctree-l3"><a class="reference internal" href="#read">read</a></li> <li class="toctree-l3"><a class="reference internal" href="#read">read</a></li>
<li class="toctree-l3"><a class="reference internal" href="#peek">peek</a></li>
<li class="toctree-l3"><a class="reference internal" href="#clear">clear</a></li> <li class="toctree-l3"><a class="reference internal" href="#clear">clear</a></li>
<li class="toctree-l3"><a class="reference internal" href="#rm">rm</a></li>
<li class="toctree-l3"><a class="reference internal" href="#scriptrunning">scriptRunning</a></li> <li class="toctree-l3"><a class="reference internal" href="#scriptrunning">scriptRunning</a></li>
<li class="toctree-l3"><a class="reference internal" href="#scriptkill">scriptKill</a></li> <li class="toctree-l3"><a class="reference internal" href="#scriptkill">scriptKill</a></li>
<li class="toctree-l3"><a class="reference internal" href="#getscriptram">getScriptRam</a></li> <li class="toctree-l3"><a class="reference internal" href="#getscriptram">getScriptRam</a></li>
@ -1566,6 +1651,7 @@ you create in functions such as <a class="reference external" href="https://deve
<li class="toctree-l2"><a class="reference internal" href="netscripthacknetnodeapi.html"> Hacknet Node API</a></li> <li class="toctree-l2"><a class="reference internal" href="netscripthacknetnodeapi.html"> Hacknet Node API</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptixapi.html"> Trade Information eXchange (TIX) API</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptixapi.html"> Trade Information eXchange (TIX) API</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html"> Singularity Functions</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html"> Singularity Functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>

@ -53,8 +53,6 @@
<div class="section" id="netscript-loops-and-conditionals"> <div class="section" id="netscript-loops-and-conditionals">
<h1>Netscript Loops and Conditionals<a class="headerlink" href="#netscript-loops-and-conditionals" title="Permalink to this headline"></a></h1> <h1>Netscript Loops and Conditionals<a class="headerlink" href="#netscript-loops-and-conditionals" title="Permalink to this headline"></a></h1>
<div class="section" id="loops-and-conditionals">
<h2>Loops and Conditionals<a class="headerlink" href="#loops-and-conditionals" title="Permalink to this headline"></a></h2>
<p>Netscript loops and conditionals are the same as Javascript. However, the one caveat is that when declaring variables such as the <p>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 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:</p> documentation for loops/conditionals here:</p>
@ -86,7 +84,6 @@ Otherwise, the money available on the server will be grown using the grow() Nets
<span class="p">}</span> <span class="p">}</span>
</pre></div> </pre></div>
</div> </div>
</div>
</div> </div>
@ -101,16 +98,14 @@ Otherwise, the money available on the server will be grown using the grow() Nets
<li class="toctree-l1 current"><a class="reference internal" href="netscript.html"> Netscript</a><ul class="current"> <li class="toctree-l1 current"><a class="reference internal" href="netscript.html"> Netscript</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="netscriptdatatypes.html"> Data Types and Variables</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptdatatypes.html"> Data Types and Variables</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptoperators.html"> Operators</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptoperators.html"> Operators</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#"> Loops and Conditionals</a><ul> <li class="toctree-l2 current"><a class="current reference internal" href="#"> Loops and Conditionals</a></li>
<li class="toctree-l3"><a class="reference internal" href="#loops-and-conditionals">Loops and Conditionals</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="netscriptscriptarguments.html"> Script Arguments</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptscriptarguments.html"> Script Arguments</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html"> Basic Functions</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html"> Basic Functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptadvancedfunctions.html"> Advanced Functions</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptadvancedfunctions.html"> Advanced Functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscripthacknetnodeapi.html"> Hacknet Node API</a></li> <li class="toctree-l2"><a class="reference internal" href="netscripthacknetnodeapi.html"> Hacknet Node API</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptixapi.html"> Trade Information eXchange (TIX) API</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptixapi.html"> Trade Information eXchange (TIX) API</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html"> Singularity Functions</a></li> <li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html"> Singularity Functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>

161
doc/build/html/netscriptmisc.html vendored Normal file

@ -0,0 +1,161 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="English">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Netscript Miscellaneous &#8212; Bitburner 1.0 documentation</title>
<link rel="stylesheet" href="_static/agogo.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="Netscript Singularity Functions" href="netscriptsingularityfunctions.html" />
</head>
<body>
<div class="header-wrapper" role="banner">
<div class="header">
<div class="headertitle"><a
href="index.html">Bitburner 1.0 documentation</a></div>
<div class="rel" role="navigation" aria-label="related navigation">
<a href="netscriptsingularityfunctions.html" title="Netscript Singularity Functions"
accesskey="P">previous</a> |
<a href="genindex.html" title="General Index"
accesskey="I">index</a>
</div>
</div>
</div>
<div class="content-wrapper">
<div class="content">
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="netscript-miscellaneous">
<h1>Netscript Miscellaneous<a class="headerlink" href="#netscript-miscellaneous" title="Permalink to this headline"></a></h1>
<div class="section" id="comments">
<h2>Comments<a class="headerlink" href="#comments" title="Permalink to this headline"></a></h2>
<p>Netscript supports comments using the same syntax as <a class="reference external" href="https://www.w3schools.com/js/js_comments.asp">Javascript comments</a>.
Comments are not evaluated as code, and can be used to document and/or explain code:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">//</span><span class="n">This</span> <span class="ow">is</span> <span class="n">a</span> <span class="n">comment</span> <span class="ow">and</span> <span class="n">will</span> <span class="ow">not</span> <span class="n">get</span> <span class="n">executed</span> <span class="n">even</span> <span class="n">though</span> <span class="n">its</span> <span class="ow">in</span> <span class="n">the</span> <span class="n">code</span>
<span class="o">/*</span> <span class="n">Multi</span>
<span class="o">*</span> <span class="n">line</span>
<span class="o">*</span> <span class="n">comment</span> <span class="o">*/</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;This code will actually get executed&quot;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="javascript-math-module">
<h2>Javascript Math Module<a class="headerlink" href="#javascript-math-module" title="Permalink to this headline"></a></h2>
<p>The <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math">Javascript Math Module</a> is
supported in Netscript and is used in the same way:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">numThreads</span> <span class="o">=</span> <span class="n">Math</span><span class="o">.</span><span class="n">floor</span><span class="p">(</span><span class="n">getServerRam</span><span class="p">(</span><span class="s2">&quot;foodnstuff&quot;</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span> <span class="o">/</span> <span class="mf">3.4</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="javascript-date-module">
<h2>Javascript Date Module<a class="headerlink" href="#javascript-date-module" title="Permalink to this headline"></a></h2>
<p>The <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date">Javascript Date Module</a> is supported in Netscript.
However, since the 'new' operator does not work in Netscript, only the Date module's static functions can be used:</p>
<ul class="simple">
<li>now()</li>
<li>UTC()</li>
<li>Parse()</li>
<li>Maybe some others I don't know about</li>
</ul>
<p>Example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">time</span> <span class="o">=</span> <span class="n">Date</span><span class="o">.</span><span class="n">now</span><span class="p">();</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sidebar">
<h3>Table Of Contents</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="netscript.html"> Netscript</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="netscriptdatatypes.html"> Data Types and Variables</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptoperators.html"> Operators</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptloopsandconditionals.html"> Loops and Conditionals</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptscriptarguments.html"> Script Arguments</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html"> Basic Functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptadvancedfunctions.html"> Advanced Functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscripthacknetnodeapi.html"> Hacknet Node API</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptixapi.html"> Trade Information eXchange (TIX) API</a></li>
<li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html"> Singularity Functions</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#"> Miscellaneous</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#comments">Comments</a></li>
<li class="toctree-l3"><a class="reference internal" href="#javascript-math-module">Javascript Math Module</a></li>
<li class="toctree-l3"><a class="reference internal" href="#javascript-date-module">Javascript Date Module</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<div role="search">
<h3 style="margin-top: 1.5em;">Search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="clearer"></div>
</div>
</div>
<div class="footer-wrapper">
<div class="footer">
<div class="left">
<div role="navigation" aria-label="related navigaton">
<a href="netscriptsingularityfunctions.html" title="Netscript Singularity Functions"
>previous</a> |
<a href="genindex.html" title="General Index"
>index</a>
</div>
<div role="note" aria-label="source link">
<br/>
<a href="_sources/netscriptmisc.rst.txt"
rel="nofollow">Show Source</a>
</div>
</div>
<div class="right">
<div class="footer" role="contentinfo">
&#169; Copyright 2017, Bitburner.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.4.
</div>
</div>
<div class="clearer"></div>
</div>
</div>
</body>
</html>

@ -24,6 +24,7 @@
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="genindex.html" /> <link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" /> <link rel="search" title="Search" href="search.html" />
<link rel="next" title="Netscript Miscellaneous" href="netscriptmisc.html" />
<link rel="prev" title="Netscript Trade Information eXchange (TIX) API" href="netscriptixapi.html" /> <link rel="prev" title="Netscript Trade Information eXchange (TIX) API" href="netscriptixapi.html" />
</head> </head>
<body> <body>
@ -34,6 +35,8 @@
<div class="rel" role="navigation" aria-label="related navigation"> <div class="rel" role="navigation" aria-label="related navigation">
<a href="netscriptixapi.html" title="Netscript Trade Information eXchange (TIX) API" <a href="netscriptixapi.html" title="Netscript Trade Information eXchange (TIX) API"
accesskey="P">previous</a> | accesskey="P">previous</a> |
<a href="netscriptmisc.html" title="Netscript Miscellaneous"
accesskey="N">next</a> |
<a href="genindex.html" title="General Index" <a href="genindex.html" title="General Index"
accesskey="I">index</a> accesskey="I">index</a>
</div> </div>
@ -696,6 +699,7 @@ This script will be run with no arguments and 1 thread. It must be located on yo
<li class="toctree-l3"><a class="reference internal" href="#installaugmentations">installAugmentations</a></li> <li class="toctree-l3"><a class="reference internal" href="#installaugmentations">installAugmentations</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -720,6 +724,8 @@ This script will be run with no arguments and 1 thread. It must be located on yo
<div role="navigation" aria-label="related navigaton"> <div role="navigation" aria-label="related navigaton">
<a href="netscriptixapi.html" title="Netscript Trade Information eXchange (TIX) API" <a href="netscriptixapi.html" title="Netscript Trade Information eXchange (TIX) API"
>previous</a> | >previous</a> |
<a href="netscriptmisc.html" title="Netscript Miscellaneous"
>next</a> |
<a href="genindex.html" title="General Index" <a href="genindex.html" title="General Index"
>index</a> >index</a>
</div> </div>

Binary file not shown.

File diff suppressed because one or more lines are too long

43
doc/source/.tags Normal file

@ -0,0 +1,43 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.8 //
author .\conf.py /^author = 'Bitburner'$/;" v
copyright .\conf-guzzle.py /^copyright = u'2017, Daniel Xie'$/;" v
copyright .\conf.py /^copyright = '2017, Bitburner'$/;" v
exclude_patterns .\conf-guzzle.py /^exclude_patterns = ['_build']$/;" v
exclude_patterns .\conf.py /^exclude_patterns = []$/;" v
extensions .\conf-guzzle.py /^extensions = []$/;" v
extensions .\conf.py /^extensions = ['sphinx.ext.autodoc',$/;" v
guzzle_sphinx_theme .\conf-guzzle.py /^import guzzle_sphinx_theme$/;" i
html_show_sourcelink .\conf-guzzle.py /^html_show_sourcelink = False$/;" v
html_static_path .\conf.py /^html_static_path = ['ystatic']$/;" v
html_theme .\conf-guzzle.py /^html_theme = 'guzzle_sphinx_theme'$/;" v
html_theme .\conf.py /^html_theme = 'agogo'$/;" v
html_theme_options .\conf-guzzle.py /^html_theme_options = {$/;" v
html_theme_path .\conf-guzzle.py /^html_theme_path = guzzle_sphinx_theme.html_theme_path()$/;" v
htmlhelp_basename .\conf.py /^htmlhelp_basename = 'Bitburnerdoc'$/;" v
intersphinx_mapping .\conf.py /^intersphinx_mapping = {'https:\/\/docs.python.org\/': None}$/;" v
language .\conf.py /^language = 'English'$/;" v
latex_documents .\conf.py /^latex_documents = [$/;" v
latex_elements .\conf.py /^latex_elements = {$/;" v
man_pages .\conf.py /^man_pages = [$/;" v
master_doc .\conf-guzzle.py /^master_doc = 'index'$/;" v
master_doc .\conf.py /^master_doc = 'index'$/;" v
os .\conf-guzzle.py /^import sys, os, subprocess$/;" i
project .\conf-guzzle.py /^project = u'Bitburner'$/;" v
project .\conf.py /^project = 'Bitburner'$/;" v
pygments_style .\conf.py /^pygments_style = 'sphinx'$/;" v
release .\conf.py /^release = '1.0'$/;" v
source_suffix .\conf-guzzle.py /^source_suffix = '.rst'$/;" v
source_suffix .\conf.py /^source_suffix = '.rst'$/;" v
subprocess .\conf-guzzle.py /^import sys, os, subprocess$/;" i
sys .\conf-guzzle.py /^import sys, os, subprocess$/;" i
templates_path .\conf-guzzle.py /^templates_path = ['_templates']$/;" v
templates_path .\conf.py /^templates_path = ['ytemplates']$/;" v
texinfo_documents .\conf.py /^texinfo_documents = [$/;" v
todo_include_todos .\conf.py /^todo_include_todos = True$/;" v
version .\conf-guzzle.py /^version = '1.0.0'$/;" v
version .\conf.py /^version = '1.0'$/;" v

@ -23,3 +23,4 @@ to reach out to the developer!
Hacknet Node API <netscripthacknetnodeapi> Hacknet Node API <netscripthacknetnodeapi>
Trade Information eXchange (TIX) API <netscriptixapi> Trade Information eXchange (TIX) API <netscriptixapi>
Singularity Functions <netscriptsingularityfunctions> Singularity Functions <netscriptsingularityfunctions>
Miscellaneous <netscriptmisc>

@ -12,7 +12,7 @@ hack
.. js:function:: hack(hostname/ip) .. js:function:: hack(hostname/ip)
:param string hostname/ip: IP or hostname of the target server to hack :param string hostname/ip: IP or hostname of the target server to hack
:returns: True if the hack is successful, false otherwise :returns: The amount of money stolen if the hack is successful, and zero otherwise
Function that is used to try and hack servers to steal money and gain hacking experience. The runtime for this command depends 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 on your hacking level and the target server's security level. In order to hack a server you must first gain root access
@ -72,10 +72,9 @@ weaken
sleep sleep
^^^^^ ^^^^^
.. js:function:: sleep(n[, log=true]) .. js:function:: sleep(n)
:param number n: Number of milliseconds to sleep :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. Suspends the script for n milliseconds.
@ -97,6 +96,39 @@ tprint
Prints a value or a variable to the Terminal Prints a value or a variable to the Terminal
clearLog
^^^^^^^^
.. js:function:: clearLog()
Clears the script's logs
disableLog
^^^^^^^^^^
.. js:function:: disableLog(fn)
:param string fn: 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.
Notable functions that cannot have their logs disabled: run, exec, exit
enableLog
^^^^^^^^^
.. js:function:: enableLog(fn)
:param string fn: 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')
scan scan
^^^^ ^^^^
@ -304,7 +336,8 @@ killall
:param string hostname/ip: IP or hostname of the server on which to kill all scripts :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. 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.
exit exit
@ -640,15 +673,6 @@ getPurchasedServers
Returns an array with either the hostnames or IPs 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.
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 write
^^^^^ ^^^^^
@ -685,6 +709,18 @@ read
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 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. the text file does not exist, an empty string will be returned.
peek
^^^^
.. js:function:: peek(port)
:param number port: Port to peek. Must be an integer between 1 and 10
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 `Netscript Ports work here <http://bitburner.wikia.com/wiki/Netscript_Ports>`_.
clear clear
^^^^^ ^^^^^
@ -698,6 +734,16 @@ clear
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 *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.
rm
^^
.. js:function:: rm(fn)
:param string fn: Filename of file to remove. Must include the extension
:returns: True if it successfully deletes the file, and false otherwise
Removes the specified file from the current server. This function works for every file type except message (.msg) files.
scriptRunning scriptRunning
^^^^^^^^^^^^^ ^^^^^^^^^^^^^

@ -2,9 +2,6 @@ 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 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 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: documentation for loops/conditionals here:

@ -0,0 +1,37 @@
Netscript Miscellaneous
=======================
Comments
--------
Netscript supports comments using the same syntax as `Javascript comments <https://www.w3schools.com/js/js_comments.asp>`_.
Comments are not evaluated as code, and can be used to document and/or explain code::
//This is a comment and will not get executed even though its in the code
/* Multi
* line
* comment */
print("This code will actually get executed");
Javascript Math Module
----------------------
The `Javascript Math Module <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math>`_ is
supported in Netscript and is used in the same way::
numThreads = Math.floor(getServerRam("foodnstuff")[1] / 3.4);
Javascript Date Module
----------------------
The `Javascript Date Module <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date>`_ is supported in Netscript.
However, since the 'new' operator does not work in Netscript, only the Date module's static functions can be used:
* now()
* UTC()
* Parse()
* Maybe some others I don't know about
Example::
time = Date.now();

@ -870,7 +870,7 @@
</span> </span>
</label> </label>
<input type ="range" max="200" min="25" <input type ="range" max="250" min="25"
step="1" name="settingsNSExecTimeRangeVal" id="settingsNSExecTimeRangeVal" value="100"> step="1" name="settingsNSExecTimeRangeVal" id="settingsNSExecTimeRangeVal" value="100">
</input> </input>
<em id="settingsNSExecTimeRangeValLabel" style="font-style: normal;"></em> <em id="settingsNSExecTimeRangeValLabel" style="font-style: normal;"></em>

2498
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

@ -1,4 +1,5 @@
import {Engine} from "./engine.js"; import {Engine} from "./engine.js";
import {showLiterature} from "./Literature.js";
import {Locations} from "./Location.js"; import {Locations} from "./Location.js";
import {Player} from "./Player.js"; import {Player} from "./Player.js";
@ -11,7 +12,7 @@ import {getRandomInt, removeElementById,
import {Reviver, Generic_toJSON, import {Reviver, Generic_toJSON,
Generic_fromJSON} from "../utils/JSONReviver.js"; Generic_fromJSON} from "../utils/JSONReviver.js";
import numeral from "../utils/numeral.min.js"; import numeral from "../utils/numeral.min.js";
import {formatNumber, isString} from "../utils/StringHelperFunctions.js"; import {formatNumber, isString, generateRandomString} from "../utils/StringHelperFunctions.js";
import {yesNoBoxCreate, yesNoTxtInpBoxCreate, import {yesNoBoxCreate, yesNoTxtInpBoxCreate,
yesNoBoxGetYesButton, yesNoBoxGetNoButton, yesNoBoxGetYesButton, yesNoBoxGetNoButton,
yesNoTxtInpBoxGetYesButton, yesNoTxtInpBoxGetNoButton, yesNoTxtInpBoxGetYesButton, yesNoTxtInpBoxGetNoButton,
@ -51,7 +52,7 @@ Reviver.constructors.CorporationState = CorporationState;
/* Constants */ /* Constants */
var TOTALSHARES = 1e9; //Total number of shares you have at your company var TOTALSHARES = 1e9; //Total number of shares you have at your company
var CyclesPerMarketCycle = 100; var CyclesPerMarketCycle = 75;
var CyclesPerIndustryStateCycle = CyclesPerMarketCycle / companyStates.length; var CyclesPerIndustryStateCycle = CyclesPerMarketCycle / companyStates.length;
var SecsPerMarketCycle = CyclesPerMarketCycle / 5; var SecsPerMarketCycle = CyclesPerMarketCycle / 5;
var Cities = ["Aevum", "Chongqing", "Sector-12", "New Tokyo", "Ishima", "Volhaven"]; var Cities = ["Aevum", "Chongqing", "Sector-12", "New Tokyo", "Ishima", "Volhaven"];
@ -352,7 +353,7 @@ Product.prototype.finishProduct = function(employeeProd, industry) {
this.calculateRating(industry); this.calculateRating(industry);
var advMult = 1 + (Math.pow(this.advCost, 0.1) / 100); var advMult = 1 + (Math.pow(this.advCost, 0.1) / 100);
console.log("advMult: " + advMult); console.log("advMult: " + advMult);
this.mku = 100 / (advMult * this.qlt * (busRatio + mgmtRatio)); this.mku = 100 / (advMult * Math.pow((this.qlt + 0.001), 0.9) * (busRatio + mgmtRatio));
this.dmd = industry.awareness === 0 ? 20 : Math.min(100, advMult * (100 * (industry.popularity / industry.awareness))); this.dmd = industry.awareness === 0 ? 20 : Math.min(100, advMult * (100 * (industry.popularity / industry.awareness)));
this.cmp = getRandomInt(0, 70); this.cmp = getRandomInt(0, 70);
@ -440,33 +441,47 @@ var IndustryStartingCosts = {
var IndustryDescriptions = { var IndustryDescriptions = {
Energy: "Engage in the production and distribution of energy.<br><br>" + Energy: "Engage in the production and distribution of energy.<br><br>" +
"Starting cost: " + numeral(IndustryStartingCosts.Energy).format("$0.000a"), "Starting cost: " + numeral(IndustryStartingCosts.Energy).format("$0.000a") + "<br>" +
"Recommended starting Industry: NO",
Utilities: "Distributes water and provides wastewater services.<br><br>" + Utilities: "Distributes water and provides wastewater services.<br><br>" +
"Starting cost: " + numeral(IndustryStartingCosts.Utilities).format("$0.000a"), "Starting cost: " + numeral(IndustryStartingCosts.Utilities).format("$0.000a") + "<br>" +
"Recommended starting Industry: NO",
Agriculture: "Cultive crops and breed livestock to produce food.<br><br>" + Agriculture: "Cultive crops and breed livestock to produce food.<br><br>" +
"Starting cost: " + numeral(IndustryStartingCosts.Agriculture).format("$0.000a"), "Starting cost: " + numeral(IndustryStartingCosts.Agriculture).format("$0.000a") + "<br>" +
"Recommended starting Industry: YES",
Fishing: "Produce food through the breeding and processing of fish and fish products<br><br>" + Fishing: "Produce food through the breeding and processing of fish and fish products<br><br>" +
"Starting cost: " + numeral(IndustryStartingCosts.Fishing).format("$0.000a"), "Starting cost: " + numeral(IndustryStartingCosts.Fishing).format("$0.000a") + "<br>" +
"Recommended starting Industry: NO",
Mining: "Extract and process metals from the earth.<br><br>" + Mining: "Extract and process metals from the earth.<br><br>" +
"Starting cost: " + numeral(IndustryStartingCosts.Mining).format("$0.000a"), "Starting cost: " + numeral(IndustryStartingCosts.Mining).format("$0.000a") + "<br>" +
"Recommended starting Industry: NO",
Food: "Create your own restaurants all around the world.<br><br>" + Food: "Create your own restaurants all around the world.<br><br>" +
"Starting cost: " + numeral(IndustryStartingCosts.Food).format("$0.000a"), "Starting cost: " + numeral(IndustryStartingCosts.Food).format("$0.000a") + "<br>" +
"Recommended starting Industry: YES",
Tobacco: "Create and distribute tobacco and tobacco-related products.<br><br>" + Tobacco: "Create and distribute tobacco and tobacco-related products.<br><br>" +
"Starting cost: " + numeral(IndustryStartingCosts.Tobacco).format("$0.000a"), "Starting cost: " + numeral(IndustryStartingCosts.Tobacco).format("$0.000a") + "<br>" +
"Recommended starting Industry: YES",
Chemical: "Product industrial chemicals<br><br>" + Chemical: "Product industrial chemicals<br><br>" +
"Starting cost: " + numeral(IndustryStartingCosts.Chemical).format("$0.000a"), "Starting cost: " + numeral(IndustryStartingCosts.Chemical).format("$0.000a") + "<br>" +
"Recommended starting Industry: NO",
Pharmaceutical: "Discover, develop, and create new pharmaceutical drugs.<br><br>" + Pharmaceutical: "Discover, develop, and create new pharmaceutical drugs.<br><br>" +
"Starting cost: " + numeral(IndustryStartingCosts.Pharmaceutical).format("$0.000a"), "Starting cost: " + numeral(IndustryStartingCosts.Pharmaceutical).format("$0.000a") + "<br>" +
"Recommended starting Industry: NO",
Computer: "Develop and manufacture new computer hardware and networking infrastructures.<br><br>" + Computer: "Develop and manufacture new computer hardware and networking infrastructures.<br><br>" +
"Starting cost: " + numeral(IndustryStartingCosts.Computer).format("$0.000a"), "Starting cost: " + numeral(IndustryStartingCosts.Computer).format("$0.000a") + "<br>" +
"Recommended starting Industry: NO",
Robotics: "Develop and create robots.<br><br>" + Robotics: "Develop and create robots.<br><br>" +
"Starting cost: " + numeral(IndustryStartingCosts.Robotics).format("$0.000a"), "Starting cost: " + numeral(IndustryStartingCosts.Robotics).format("$0.000a") + "<br>" +
"Recommended starting Industry: NO",
Software: "Develop computer software and create AI Cores.<br><br>" + Software: "Develop computer software and create AI Cores.<br><br>" +
"Starting cost: " + numeral(IndustryStartingCosts.Software).format("$0.000a"), "Starting cost: " + numeral(IndustryStartingCosts.Software).format("$0.000a") + "<br>" +
"Recommended starting Industry: YES",
Healthcare: "Create and manage hospitals.<br><br>" + Healthcare: "Create and manage hospitals.<br><br>" +
"Starting cost: " + numeral(IndustryStartingCosts.Healthcare).format("$0.000a"), "Starting cost: " + numeral(IndustryStartingCosts.Healthcare).format("$0.000a") + "<br>" +
"Recommended starting Industry: NO",
RealEstate: "Develop and manuage real estate properties.<br><br>" + RealEstate: "Develop and manuage real estate properties.<br><br>" +
"Starting cost: " + numeral(IndustryStartingCosts.RealEstate).format("$0.000a"), "Starting cost: " + numeral(IndustryStartingCosts.RealEstate).format("$0.000a") + "<br>" +
"Recommended starting Industry: NO",
} }
var ProductRatingWeights = { var ProductRatingWeights = {
@ -624,7 +639,7 @@ Industry.prototype.init = function() {
this.sciFac = 0.7; this.sciFac = 0.7;
this.robFac = 0.05; this.robFac = 0.05;
this.aiFac = 0.3; this.aiFac = 0.3;
this.advFac = 0.2; this.advFac = 0.07;
this.reqMats = { this.reqMats = {
"Hardware": 0.1, "Hardware": 0.1,
"Metal": 0.25, "Metal": 0.25,
@ -637,7 +652,7 @@ Industry.prototype.init = function() {
this.sciFac = 0.6; this.sciFac = 0.6;
this.robFac = 0.3; this.robFac = 0.3;
this.aiFac = 0.3; this.aiFac = 0.3;
this.advFac = 0.2; this.advFac = 0.07;
this.reqMats = { this.reqMats = {
"Hardware": 0.1, "Hardware": 0.1,
"Metal": 0.2, "Metal": 0.2,
@ -650,7 +665,7 @@ Industry.prototype.init = function() {
this.hwFac = 0.2; this.hwFac = 0.2;
this.robFac = 0.3; this.robFac = 0.3;
this.aiFac = 0.3; this.aiFac = 0.3;
this.advFac = 0.05; this.advFac = 0.04;
this.reqMats = { this.reqMats = {
"Water": 0.5, "Water": 0.5,
"Energy": 0.5, "Energy": 0.5,
@ -663,7 +678,7 @@ Industry.prototype.init = function() {
this.hwFac = 0.35; this.hwFac = 0.35;
this.robFac = 0.5; this.robFac = 0.5;
this.aiFac = 0.2; this.aiFac = 0.2;
this.advFac = 0.15; this.advFac = 0.06;
this.reqMats = { this.reqMats = {
"Energy": 0.5, "Energy": 0.5,
} }
@ -675,7 +690,7 @@ Industry.prototype.init = function() {
this.hwFac = 0.4; this.hwFac = 0.4;
this.robFac = 0.5; this.robFac = 0.5;
this.aiFac = 0.5; this.aiFac = 0.5;
this.advFac = 0.05; this.advFac = 0.04;
this.reqMats = { this.reqMats = {
"Energy": 0.8, "Energy": 0.8,
} }
@ -687,7 +702,7 @@ Industry.prototype.init = function() {
this.hwFac = 0.15; this.hwFac = 0.15;
this.robFac = 0.3; this.robFac = 0.3;
this.aiFac = 0.25; this.aiFac = 0.25;
this.advFac = 0.75; this.advFac = 0.25;
this.reFac = 0.05; this.reFac = 0.05;
this.reqMats = { this.reqMats = {
"Food": 0.5, "Food": 0.5,
@ -702,7 +717,7 @@ Industry.prototype.init = function() {
this.hwFac = 0.15; this.hwFac = 0.15;
this.robFac = 0.2; this.robFac = 0.2;
this.aiFac = 0.15; this.aiFac = 0.15;
this.advFac = 0.6; this.advFac = 0.2;
this.reqMats = { this.reqMats = {
"Plants": 1, "Plants": 1,
"Water": 0.2, "Water": 0.2,
@ -715,7 +730,7 @@ Industry.prototype.init = function() {
this.hwFac = 0.2; this.hwFac = 0.2;
this.robFac = 0.25; this.robFac = 0.25;
this.aiFac = 0.2; this.aiFac = 0.2;
this.advFac = 0.1; this.advFac = 0.05;
this.reqMats = { this.reqMats = {
"Plants": 1, "Plants": 1,
"Energy": 0.5, "Energy": 0.5,
@ -729,7 +744,7 @@ Industry.prototype.init = function() {
this.hwFac = 0.15; this.hwFac = 0.15;
this.robFac = 0.25; this.robFac = 0.25;
this.aiFac = 0.2; this.aiFac = 0.2;
this.advFac = 0.55; this.advFac = 0.15;
this.reqMats = { this.reqMats = {
"Chemicals": 2, "Chemicals": 2,
"Energy": 1, "Energy": 1,
@ -744,7 +759,7 @@ Industry.prototype.init = function() {
this.sciFac = 0.65; this.sciFac = 0.65;
this.robFac = 0.4; this.robFac = 0.4;
this.aiFac = 0.2; this.aiFac = 0.2;
this.advFac = 0.5; this.advFac = 0.17;
this.reqMats = { this.reqMats = {
"Metal": 2.5, "Metal": 2.5,
"Energy": 1, "Energy": 1,
@ -756,7 +771,7 @@ Industry.prototype.init = function() {
this.reFac = 0.35; this.reFac = 0.35;
this.sciFac = 0.7; this.sciFac = 0.7;
this.aiFac = 0.4; this.aiFac = 0.4;
this.advFac = 0.6; this.advFac = 0.2;
this.hwFac = 0.2; this.hwFac = 0.2;
this.reqMats = { this.reqMats = {
"Hardware": 5, "Hardware": 5,
@ -767,7 +782,7 @@ Industry.prototype.init = function() {
break; break;
case Industries.Software: case Industries.Software:
this.sciFac = 0.7; this.sciFac = 0.7;
this.advFac = 0.5; this.advFac = 0.18;
this.hwFac = 0.25; this.hwFac = 0.25;
this.reFac = 0.1; this.reFac = 0.1;
this.aiFac = 0.1; this.aiFac = 0.1;
@ -782,7 +797,10 @@ Industry.prototype.init = function() {
case Industries.Healthcare: case Industries.Healthcare:
//reFac is unique for this bc it diminishes greatly per city. Handle this separately in code? //reFac is unique for this bc it diminishes greatly per city. Handle this separately in code?
this.sciFac = 0.75; this.sciFac = 0.75;
this.advFac = 0.3; this.advFac = 0.1;
this.hwFac = 0.1;
this.robFac = 0.1;
this.aiFac = 0.1;
this.reqMats = { this.reqMats = {
"Robots": 10, "Robots": 10,
"AICores": 5, "AICores": 5,
@ -794,7 +812,9 @@ Industry.prototype.init = function() {
case Industries.RealEstate: case Industries.RealEstate:
this.robFac = 0.6; this.robFac = 0.6;
this.aiFac = 0.6; this.aiFac = 0.6;
this.advFac = 0.65; this.advFac = 0.25;
this.sciFac = 0.05;
this.hwFac = 0.05;
this.reqMats = { this.reqMats = {
"Metal": 20, "Metal": 20,
"Energy": 10, "Energy": 10,
@ -1027,18 +1047,7 @@ Industry.prototype.processMaterials = function(marketCycles=1, company) {
var mat = warehouse.materials[this.prodMats[0]]; var mat = warehouse.materials[this.prodMats[0]];
//Calculate the maximum production of this material based //Calculate the maximum production of this material based
//on the office's productivity //on the office's productivity
var total = office.employeeProd[EmployeePositions.Operations] + var maxProd = this.getOfficeProductivity(office) * this.prodMult * company.getProductionMultiplier(), prod;
office.employeeProd[EmployeePositions.Engineer] +
office.employeeProd[EmployeePositions.Management], ratio;
if (total === 0) {
ratio = 0;
} else {
ratio = (office.employeeProd[EmployeePositions.Operations] / total) *
(office.employeeProd[EmployeePositions.Engineer] / total) *
(office.employeeProd[EmployeePositions.Management] / total);
ratio = Math.max(0.01, ratio); //Minimum ratio value if you have employees
}
var maxProd = 2 * ratio * Math.pow(total, 0.3), prod;
if (mat.prdman[0]) { if (mat.prdman[0]) {
//Production is manually limited //Production is manually limited
@ -1046,7 +1055,7 @@ Industry.prototype.processMaterials = function(marketCycles=1, company) {
} else { } else {
prod = maxProd; prod = maxProd;
} }
prod *= (SecsPerMarketCycle * marketCycles * this.prodMult * company.getProductionMultiplier()); //Convert production from per second to per market cycle prod *= (SecsPerMarketCycle * marketCycles); //Convert production from per second to per market cycle
//Calculate net change in warehouse storage making //Calculate net change in warehouse storage making
//the produced materials will cost //the produced materials will cost
var totalMatSize = 0; var totalMatSize = 0;
@ -1153,10 +1162,12 @@ Industry.prototype.processMaterials = function(marketCycles=1, company) {
markup = mat.bCost / sCost; markup = mat.bCost / sCost;
} }
} }
var businessFactor = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]); //var businessFactor = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]);
var maxSell = (mat.qlt + .001) * mat.dmd * (100 - mat.cmp)/100 * markup * businessFactor * var businessFactor = this.getBusinessFactor(office); //Business employee productivity
Math.pow(this.awareness + 1, 0.05) * Math.pow(this.popularity + 1, 0.07) * company.getSalesMultiplier() * var advertisingFactor = this.getAdvertisingFactors()[0]; //Awareness + popularity
(this.awareness === 0 ? 0.01 : Math.max((this.popularity + .001) / this.awareness, 0.01)); var marketFactor = this.getMarketFactor(mat); //Competition + demand
var maxSell = (mat.qlt + .001) * marketFactor * markup * businessFactor *
company.getSalesMultiplier() * advertisingFactor;
var sellAmt; var sellAmt;
if (mat.sllman[1] !== -1) { if (mat.sllman[1] !== -1) {
@ -1286,18 +1297,7 @@ Industry.prototype.processProduct = function(marketCycles=1, product, corporatio
case "PRODUCTION": case "PRODUCTION":
//Calculate the maximum production of this material based //Calculate the maximum production of this material based
//on the office's productivity //on the office's productivity
var total = office.employeeProd[EmployeePositions.Operations] + var maxProd = this.getOfficeProductivity(office, {forProduct:true}) *
office.employeeProd[EmployeePositions.Engineer] +
office.employeeProd[EmployeePositions.Management], ratio;
if (total === 0) {
ratio = 0;
} else {
ratio = (office.employeeProd[EmployeePositions.Operations] / total) *
(office.employeeProd[EmployeePositions.Engineer] / total) *
(office.employeeProd[EmployeePositions.Management] / total);
ratio = Math.max(0.01, ratio); //Minimum ratio value if you have employees
}
var maxProd = ratio * Math.pow(total, 0.2) *
corporation.getProductionMultiplier() * this.prodMult, prod; corporation.getProductionMultiplier() * this.prodMult, prod;
//Account for whether production is manually limited //Account for whether production is manually limited
@ -1308,7 +1308,6 @@ Industry.prototype.processProduct = function(marketCycles=1, product, corporatio
} }
prod *= (SecsPerMarketCycle * marketCycles); prod *= (SecsPerMarketCycle * marketCycles);
//Calculate net change in warehouse storage making the Products will cost //Calculate net change in warehouse storage making the Products will cost
var netStorageSize = product.siz; var netStorageSize = product.siz;
for (var reqMatName in product.reqMats) { for (var reqMatName in product.reqMats) {
@ -1370,10 +1369,12 @@ Industry.prototype.processProduct = function(marketCycles=1, product, corporatio
markup = markupLimit / (product.sCost - product.pCost); markup = markupLimit / (product.sCost - product.pCost);
} }
} }
var businessFactor = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]); //var businessFactor = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]);
var maxSell = Math.pow(product.rat, 0.95) * product.dmd * (1-(product.cmp/100)) * corporation.getSalesMultiplier() * var businessFactor = this.getBusinessFactor(office); //Business employee productivity
markup * businessFactor * Math.pow(this.awareness + 1, 0.05) * Math.pow(this.popularity + 1, 0.07) * var advertisingFactor = this.getAdvertisingFactors()[0]; //Awareness + popularity
(this.awareness === 0 ? 0.01 : Math.max((this.popularity + .001) / this.awareness, 0.01)) ; var getMarketFactor = this.getMarketFactor(product); //Competition + demand
var maxSell = Math.pow(product.rat, 0.9) * marketFactor * corporation.getSalesMultiplier() *
markup * businessFactor * advertisingFactor;
var sellAmt; var sellAmt;
if (product.sllman[city][0] && product.sllman[city][1] > 0) { if (product.sllman[city][0] && product.sllman[city][1] > 0) {
//Sell amount is manually limited //Sell amount is manually limited
@ -1444,6 +1445,51 @@ Industry.prototype.upgrade = function(upgrade, refs) {
} }
} }
//Returns how much of a material can be produced based of office productivity (employee stats)
Industry.prototype.getOfficeProductivity = function(office, params) {
var total = office.employeeProd[EmployeePositions.Operations] +
office.employeeProd[EmployeePositions.Engineer] +
office.employeeProd[EmployeePositions.Management], ratio;
if (total === 0) {
ratio = 0;
} else {
ratio = (office.employeeProd[EmployeePositions.Operations] / total) *
(office.employeeProd[EmployeePositions.Engineer] / total) *
(office.employeeProd[EmployeePositions.Management] / total);
ratio = Math.max(0.01, ratio); //Minimum ratio value if you have employees
}
if (params && params.forProduct) {
return ratio * Math.pow(total, 0.2);
} else {
return 2 * ratio * Math.pow(total, 0.3);
}
}
//Returns a multiplier based on the office' 'Business' employees that affects sales
Industry.prototype.getBusinessFactor = function(office) {
var ratioMult = 1;
if (office.employeeProd["total"] > 0) {
ratioMult = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]);
}
return ratioMult * Math.pow(1 + office.employeeProd[EmployeePositions.Business], 0.1);
}
//Returns a set of multipliers based on the Industry's awareness, popularity, and advFac. This
//multiplier affects sales. The result is:
// [Total sales mult, total awareness mult, total pop mult, awareness/pop ratio mult]
Industry.prototype.getAdvertisingFactors = function() {
var awarenessFac = Math.pow(this.awareness + 1, this.advFac);
var popularityFac = Math.pow(this.popularity + 1, this.advFac);
var ratioFac = (this.awareness === 0 ? 0.01 : Math.max((this.popularity + .001) / this.awareness, 0.01));
var totalFac = awarenessFac * popularityFac * ratioFac;
return [totalFac, awarenessFac, popularityFac, ratioFac];
}
//Returns a multiplier based on a materials demand and competition that affects sales
Industry.prototype.getMarketFactor = function(mat) {
return mat.dmd * (100 - mat.cmp)/100;
}
Industry.prototype.toJSON = function() { Industry.prototype.toJSON = function() {
return Generic_toJSON("Industry", this); return Generic_toJSON("Industry", this);
} }
@ -1460,7 +1506,8 @@ var EmployeePositions = {
Business: "Business", Business: "Business",
Management: "Management", Management: "Management",
RandD: "Research & Development", RandD: "Research & Development",
Unassigned:"Unassigned" Training:"Training",
Unassigned:"Unassigned",
} }
function Employee(params={}) { function Employee(params={}) {
@ -1499,6 +1546,15 @@ Employee.prototype.process = function(marketCycles=1, office) {
this.cha -= det; this.cha -= det;
} }
//Training
var trainingEff = gain * Math.random();
if (this.pos === EmployeePositions.Training) {
//To increase creativity and intelligence special upgrades are needed
this.cha += trainingEff;
this.exp += trainingEff;
this.eff += trainingEff;
}
//Weight based on how full office is //Weight based on how full office is
//Too many employees = more likely to decrease energy and happiness //Too many employees = more likely to decrease energy and happiness
var officeCapacityWeight = 0.5 * (office.employees.length / office.size - 0.5); var officeCapacityWeight = 0.5 * (office.employees.length / office.size - 0.5);
@ -1544,6 +1600,7 @@ Employee.prototype.calculateProductivity = function(corporation) {
(0.5 * effEff); (0.5 * effEff);
break; break;
case EmployeePositions.Unassigned: case EmployeePositions.Unassigned:
case EmployeePositions.Training:
prodMult = 0; prodMult = 0;
break; break;
default: default:
@ -1822,6 +1879,40 @@ OfficeSpace.prototype.hireEmployee = function(employee, parentRefs) {
yesNoTxtInpBoxCreate("Give your employee a nickname!"); yesNoTxtInpBoxCreate("Give your employee a nickname!");
} }
OfficeSpace.prototype.hireRandomEmployee = function(parentRefs) {
var company = parentRefs.corporation, division = parentRefs.division;
if (document.getElementById("cmpy-mgmt-hire-employee-popup") != null) {return;}
//Generate three random employees (meh, decent, amazing)
var mult = getRandomInt(76, 100)/100;
var int = getRandomInt(50, 100),
cha = getRandomInt(50, 100),
exp = getRandomInt(50, 100),
cre = getRandomInt(50, 100),
eff = getRandomInt(50, 100),
sal = 2.2 * (int + cha + exp + cre + eff);
var emp = new Employee({
intelligence: int * mult,
charisma: cha * mult,
experience: exp * mult,
creativity: cre * mult,
efficiency: eff * mult,
salary: sal * mult,
});
var name = generateRandomString(7);
for (var i = 0; i < this.employees.length; ++i) {
if (this.employees[i].name === name) {
return this.hireRandomEmployee(parentRefs);
}
}
emp.name = name;
this.employees.push(emp);
company.displayDivisionContent(division, currentCityUi);
}
//Finds the first unassigned employee and assigns its to the specified job //Finds the first unassigned employee and assigns its to the specified job
OfficeSpace.prototype.assignEmployeeToJob = function(job) { OfficeSpace.prototype.assignEmployeeToJob = function(job) {
for (var i = 0; i < this.employees.length; ++i) { for (var i = 0; i < this.employees.length; ++i) {
@ -1970,8 +2061,26 @@ Warehouse.prototype.createUI = function(parentRefs) {
console.log("ERROR: Invalid state: " + industry.state); console.log("ERROR: Invalid state: " + industry.state);
break; break;
} }
//Material ratio text for tooltip
var reqRatioText = "The exact requirements for production are:<br>";
for (var matName in industry.reqMats) {
if (industry.reqMats.hasOwnProperty(matName)) {
reqRatioText += (industry.reqMats[matName] + " " + matName + "<br>");
}
}
reqRatioText += "in order to create ";
if (industry.prodMats.length > 0) {
reqRatioText += "one of each produced Material (" + industry.prodMats.join(", ") + ") ";
if (industry.makesProducts) {
reqRatioText += "or to create one of its Products";
}
} else if (industry.makesProducts) {
reqRatioText += "one of its Products";
}
industryWarehousePanel.appendChild(createElement("p", { industryWarehousePanel.appendChild(createElement("p", {
innerHTML:reqText, innerHTML:reqText, tooltipleft:reqRatioText
})); }));
//Materials //Materials
@ -2550,15 +2659,19 @@ var CorporationUnlockUpgrades = {
"This allows you to purchase exactly however many materials you need for production."], "This allows you to purchase exactly however many materials you need for production."],
//Displays each material/product's demand //Displays each material/product's demand
"2": [2, 25e9, "Market Research - Demand", "2": [2, 5e9, "Market Research - Demand",
"Mine and analyze market data to determine the demand of all resources. " + "Mine and analyze market data to determine the demand of all resources. " +
"The demand attribute, which affects sales, will be displayed for every material and product."], "The demand attribute, which affects sales, will be displayed for every material and product."],
//Display's each material/product's competition //Display's each material/product's competition
"3": [3, 25e9, "Market Data - Competition", "3": [3, 5e9, "Market Data - Competition",
"Mine and analyze market data to determine how much competition there is on the market " + "Mine and analyze market data to determine how much competition there is on the market " +
"for all resources. The competition attribute, which affects sales, will be displayed for " + "for all resources. The competition attribute, which affects sales, will be displayed for " +
"for every material and product."], "for every material and product."],
"4": [4, 10e9, "VeChain",
"Use AI and blockchain technology to identify where you can improve your supply chain systems. " +
"This upgrade will allow you to view a wide array of useful statistics about your " +
"Corporation."]
} }
//Corporation Upgrades //Corporation Upgrades
@ -2656,11 +2769,24 @@ Corporation.prototype.getState = function() {
return this.state.getState(); return this.state.getState();
} }
var numMarketCyclesPersist = 1;
Corporation.prototype.process = function(numCycles=1) { Corporation.prototype.process = function(numCycles=1) {
var corp = this; var corp = this;
this.storedCycles += numCycles; this.storedCycles += numCycles;
if (this.storedCycles >= CyclesPerIndustryStateCycle) { if (this.storedCycles >= CyclesPerIndustryStateCycle) {
var state = this.getState(), marketCycles = 1; var state = this.getState();
//Determine number of market cycles at the START state
if (state === "START") {
if (this.storedCycles >= 2*CyclesPerMarketCycle) {
//Enough cycles stored for 2+ market cycles
numMarketCyclesPersist = Math.floor(this.storedCycles / CyclesPerMarketCycle);
} else {
numMarketCyclesPersist = 1;
}
}
var marketCycles = numMarketCyclesPersist;
this.storedCycles -= (marketCycles * CyclesPerIndustryStateCycle); this.storedCycles -= (marketCycles * CyclesPerIndustryStateCycle);
this.divisions.forEach(function(ind) { this.divisions.forEach(function(ind) {
ind.process(marketCycles, state, corp); ind.process(marketCycles, state, corp);
@ -2694,13 +2820,13 @@ Corporation.prototype.process = function(numCycles=1) {
Corporation.prototype.determineValuation = function() { Corporation.prototype.determineValuation = function() {
var val, profit = (this.revenue.minus(this.expenses)).toNumber(); var val, profit = (this.revenue.minus(this.expenses)).toNumber();
if (this.public) { if (this.public) {
val = this.funds.toNumber() + (profit * 100e3); val = this.funds.toNumber() + (profit * 90e3);
val *= (Math.pow(1.1, this.divisions.length)); val *= (Math.pow(1.1, this.divisions.length));
val = Math.max(val, 0); val = Math.max(val, 0);
} else { } else {
val = 10e9 + Math.max(this.funds.toNumber(), 0) / 3; //Base valuation val = 10e9 + Math.max(this.funds.toNumber(), 0) / 3; //Base valuation
if (profit > 0) { if (profit > 0) {
val += (profit * 400e3); val += (profit * 350e3);
val *= (Math.pow(1.1, this.divisions.length)); val *= (Math.pow(1.1, this.divisions.length));
} else { } else {
val = 10e9 * Math.pow(1.1, this.divisions.length); val = 10e9 * Math.pow(1.1, this.divisions.length);
@ -2914,7 +3040,8 @@ var companyManagementDiv, companyManagementHeaderTabs, companyManagementPanel,
currentCityUi, currentCityUi,
corporationUnlockUpgrades, corporationUpgrades, corporationUnlockUpgrades, corporationUpgrades,
industryOverviewPanel, industryOverviewText, industryOverviewPanel, industryOverviewText,
industryEmployeePanel, industryEmployeeText, industryEmployeeHireButton, industryEmployeeManagementUI, industryEmployeeInfo, industryEmployeePanel, industryEmployeeText, industryEmployeeHireButton, industryEmployeeAutohireButton,
industryEmployeeManagementUI, industryEmployeeInfo, industryIndividualEmployeeInfo,
industryOfficeUpgradeSizeButton, industryOfficeUpgradeSizeButton,
industryWarehousePanel, industryWarehousePanel,
headerTabs, cityTabs; headerTabs, cityTabs;
@ -3040,12 +3167,15 @@ Corporation.prototype.updateUIHeaderTabs = function() {
}); });
//Add industry types to selector //Add industry types to selector
//Have Agriculture be first as recommended option
selector.add(createElement("option", {
text:Industries["Agriculture"], value:"Agriculture"
}))
for (var key in Industries) { for (var key in Industries) {
if (Industries.hasOwnProperty(key)) { if (key !== "Agriculture" && Industries.hasOwnProperty(key)) {
var ind = Industries[key]; var ind = Industries[key];
selector.add(createElement("option", { selector.add(createElement("option", {
text: ind, text: ind,value:key,
value:key,
})); }));
} }
} }
@ -3147,19 +3277,17 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
} }
} }
if (!hasHandbook) {
companyManagementPanel.appendChild(createElement("a", { companyManagementPanel.appendChild(createElement("a", {
class:"a-link-button", innerText:"Get Handbook", display:"inline-block", class:"a-link-button", innerText:"Getting Started Guide", display:"inline-block",
tooltip:"Get a copy of 'The Complete Handbook for Creating a Successful Corporation.'" + tooltip:"Get a copy of and read 'The Complete Handbook for Creating a Successful Corporation.' " +
"This is a .lit file that provides some tips/pointers for helping you get started with " + "This is a .lit file that guides you through the beginning of setting up a Corporation and " +
"starting and managing a Corporation.", "provides some tips/pointers for helping you get started with managing it.",
clickListener:()=>{ clickListener:()=>{
homeComp.messages.push(handbookFn); if (!hasHandbook) {homeComp.messages.push(handbookFn);}
this.displayCorporationOverviewContent(); showLiterature(handbookFn);
return false; return false;
} }
})); }));
}
//Investors //Investors
if (this.public) { if (this.public) {
@ -3180,7 +3308,7 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
type:"number", placeholder:"Shares to sell", margin:"5px", type:"number", placeholder:"Shares to sell", margin:"5px",
inputListener: ()=> { inputListener: ()=> {
var numShares = Math.round(input.value); var numShares = Math.round(input.value);
if (isNaN(numShares)) { if (isNaN(numShares) || shares <= 0) {
profitIndicator.innerText = "ERROR: Invalid value entered for number of shares to sell" profitIndicator.innerText = "ERROR: Invalid value entered for number of shares to sell"
} else if (numShares > this.numShares) { } else if (numShares > this.numShares) {
profitIndicator.innerText = "You don't have this many shares to sell!"; profitIndicator.innerText = "You don't have this many shares to sell!";
@ -3194,7 +3322,7 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
class:"a-link-button", innerText:"Sell shares", display:"inline-block", class:"a-link-button", innerText:"Sell shares", display:"inline-block",
clickListener:()=>{ clickListener:()=>{
var shares = Math.round(input.value); var shares = Math.round(input.value);
if (isNaN(shares)) { if (isNaN(shares) || shares <= 0) {
dialogBoxCreate("ERROR: Invalid value for number of shares"); dialogBoxCreate("ERROR: Invalid value for number of shares");
} else if (shares > this.numShares) { } else if (shares > this.numShares) {
dialogBoxCreate("ERROR: You don't have this many shares to sell"); dialogBoxCreate("ERROR: You don't have this many shares to sell");
@ -3247,7 +3375,7 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
inputListener: ()=> { inputListener: ()=> {
var numShares = Math.round(input.value); var numShares = Math.round(input.value);
//TODO add conditional for if player doesn't have enough money //TODO add conditional for if player doesn't have enough money
if (isNaN(numShares)) { if (isNaN(numShares) || shares <= 0) {
costIndicator.innerText = "ERROR: Invalid value entered for number of shares to buyback" costIndicator.innerText = "ERROR: Invalid value entered for number of shares to buyback"
} else if (numShares > this.issuedShares) { } else if (numShares > this.issuedShares) {
costIndicator.innerText = "There are not this many shares available to buy back. " + costIndicator.innerText = "There are not this many shares available to buy back. " +
@ -3263,7 +3391,7 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
clickListener:()=>{ clickListener:()=>{
var shares = Math.round(input.value); var shares = Math.round(input.value);
var tempStockPrice = this.sharePrice; var tempStockPrice = this.sharePrice;
if (isNaN(shares)) { if (isNaN(shares) || shares <= 0) {
dialogBoxCreate("ERROR: Invalid value for number of shares"); dialogBoxCreate("ERROR: Invalid value for number of shares");
} else if (shares > this.issuedShares) { } else if (shares > this.issuedShares) {
dialogBoxCreate("ERROR: There are not this many oustanding shares to buy back"); dialogBoxCreate("ERROR: There are not this many oustanding shares to buy back");
@ -3572,13 +3700,18 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
//Industry overview text //Industry overview text
industryOverviewText = createElement("p", {}); industryOverviewText = createElement("p", {});
industryOverviewPanel.appendChild(industryOverviewText); industryOverviewPanel.appendChild(industryOverviewText);
industryOverviewPanel.appendChild(createElement("br", {}));
//Industry overview Purchases & Upgrades //Industry overview Purchases & Upgrades
var numUpgrades = Object.keys(IndustryUpgrades).length; var numUpgrades = Object.keys(IndustryUpgrades).length;
while (division.upgrades.length < numUpgrades) {division.upgrades.push(0);} //Backwards compatibility while (division.upgrades.length < numUpgrades) {division.upgrades.push(0);} //Backwards compatibility
var industryOverviewUpgrades = createElement("div", {}); var industryOverviewUpgrades = createElement("div", {});
industryOverviewUpgrades.appendChild(createElement("h1", {innerText:"Purchases & Upgrades", margin:"4px", padding:"4px"})); industryOverviewUpgrades.appendChild(createElement("u", {
innerText:"Purchases & Upgrades", margin:"2px", padding:"2px",
fontSize:"14px",
}));
industryOverviewUpgrades.appendChild(createElement("br", {}));
for (var i = 0; i < numUpgrades; ++i) { for (var i = 0; i < numUpgrades; ++i) {
(function(i, corp, division, office) { (function(i, corp, division, office) {
var upgrade = IndustryUpgrades[i.toString()]; var upgrade = IndustryUpgrades[i.toString()];
@ -3765,10 +3898,10 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
}); });
industryEmployeePanel.appendChild(industryEmployeeText); industryEmployeePanel.appendChild(industryEmployeeText);
//Hire Employee button
industryEmployeeHireButton = createElement("a", { industryEmployeeHireButton = createElement("a", {
class:"a-link-button", class:"a-link-button",display:"inline-block",
innerText:"Hire Employee", innerText:"Hire Employee", fontSize:"13px",
display:"inline-block",
clickListener:()=>{ clickListener:()=>{
office.findEmployees({corporation:this, division:division}); office.findEmployees({corporation:this, division:division});
return false; return false;
@ -3776,9 +3909,24 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
}); });
industryEmployeePanel.appendChild(industryEmployeeHireButton); industryEmployeePanel.appendChild(industryEmployeeHireButton);
//Autohire Employee button
industryEmployeeAutohireButton = createElement("a", {
class:"a-link-button", display:"inline-block",
innerText:"Autohire Employee", fontSize:"13px",
tooltip:"Automatically hires an employee and gives him/her a random name",
clickListener:()=>{
office.hireRandomEmployee({corporation:this, division:division});
return false;
}
});
industryEmployeePanel.appendChild(industryEmployeeAutohireButton);
//Upgrade Office Size button //Upgrade Office Size button
industryEmployeePanel.appendChild(createElement("br", {}));
industryOfficeUpgradeSizeButton = createElement("a", { industryOfficeUpgradeSizeButton = createElement("a", {
class:"a-link-button", innerText:"Upgrade Office size", display:"inline-block", margin:"6px", class:"a-link-button", innerText:"Upgrade size",
display:"inline-block", margin:"6px", fontSize:"13px",
tooltip:"Upgrade the office's size so that it can hold more employees!",
clickListener:()=>{ clickListener:()=>{
var popupId = "cmpy-mgmt-upgrade-office-size-popup"; var popupId = "cmpy-mgmt-upgrade-office-size-popup";
var upgradeCost = OfficeInitialCost * Math.pow(1.07, Math.round(office.size / OfficeInitialSize)); var upgradeCost = OfficeInitialCost * Math.pow(1.07, Math.round(office.size / OfficeInitialSize));
@ -3821,9 +3969,9 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
industryEmployeePanel.appendChild(industryOfficeUpgradeSizeButton); industryEmployeePanel.appendChild(industryOfficeUpgradeSizeButton);
//Throw Office Party //Throw Office Party
industryEmployeePanel.appendChild(createElement("br",{}));
industryEmployeePanel.appendChild(createElement("a", { industryEmployeePanel.appendChild(createElement("a", {
class:"a-link-button", display:"inline-block", innerText:"Throw Office Party", class:"a-link-button", display:"inline-block", innerText:"Throw Party",
fontSize:"13px",
tooltip:"Throw an office party to increase your employee's morale and happiness", tooltip:"Throw an office party to increase your employee's morale and happiness",
clickListener:()=>{ clickListener:()=>{
var popupId = "cmpy-mgmt-throw-office-party-popup"; var popupId = "cmpy-mgmt-throw-office-party-popup";
@ -3884,6 +4032,7 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
})); }));
industryEmployeeManagementUI = createElement("div", {}); industryEmployeeManagementUI = createElement("div", {});
industryEmployeeInfo = createElement("p", {margin:"4px", padding:"4px"});
if (empManualAssignmentModeActive) { if (empManualAssignmentModeActive) {
//Employees manually assigned //Employees manually assigned
industryEmployeeManagementUI.appendChild(createElement("a", { industryEmployeeManagementUI.appendChild(createElement("a", {
@ -3899,16 +4048,15 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
})); }));
industryEmployeeManagementUI.appendChild(createElement("br", {})); industryEmployeeManagementUI.appendChild(createElement("br", {}));
industryEmployeeInfo = createElement("div", {margin:"4px", padding:"4px"}); industryIndividualEmployeeInfo = createElement("div", {margin:"4px", padding:"4px"});
var selector = createElement("select", { var selector = createElement("select", {
color: "white", backgroundColor:"black", margin:"4px", padding:"4px", color: "white", backgroundColor:"black", margin:"4px", padding:"4px",
changeListener:()=>{ changeListener:()=>{
var name = selector.options[selector.selectedIndex].text; var name = selector.options[selector.selectedIndex].text;
for (var i = 0; i < office.employees.length; ++i) { for (var i = 0; i < office.employees.length; ++i) {
if (office.employees[i].name === name) { if (office.employees[i].name === name) {
removeChildrenFromElement(industryEmployeeInfo); removeChildrenFromElement(industryIndividualEmployeeInfo);
office.employees[i].createUI(industryEmployeeInfo, this); office.employees[i].createUI(industryIndividualEmployeeInfo, this);
return; return;
} }
} }
@ -3922,9 +4070,9 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
selector.selectedIndex = -1; selector.selectedIndex = -1;
industryEmployeeManagementUI.appendChild(selector);
industryEmployeeManagementUI.appendChild(industryEmployeeInfo); industryEmployeeManagementUI.appendChild(industryEmployeeInfo);
industryEmployeeManagementUI.appendChild(selector);
industryEmployeeManagementUI.appendChild(industryIndividualEmployeeInfo);
} else { } else {
//Player only manages the number of each occupation, not who gets what job //Player only manages the number of each occupation, not who gets what job
industryEmployeeManagementUI.appendChild(createElement("a", { industryEmployeeManagementUI.appendChild(createElement("a", {
@ -3940,7 +4088,8 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
industryEmployeeManagementUI.appendChild(createElement("br", {})); industryEmployeeManagementUI.appendChild(createElement("br", {}));
var opCount = 0, engCount = 0, busCount = 0, var opCount = 0, engCount = 0, busCount = 0,
mgmtCount = 0, rndCount = 0, unassignedCount = 0; mgmtCount = 0, rndCount = 0, unassignedCount = 0,
trainingCount = 0;
for (var i = 0; i < office.employees.length; ++i) { for (var i = 0; i < office.employees.length; ++i) {
switch (office.employees[i].pos) { switch (office.employees[i].pos) {
case EmployeePositions.Operations: case EmployeePositions.Operations:
@ -3955,6 +4104,8 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
++rndCount; break; ++rndCount; break;
case EmployeePositions.Unassigned: case EmployeePositions.Unassigned:
++unassignedCount; break; ++unassignedCount; break;
case EmployeePositions.Training:
++trainingCount; break;
default: default:
console.log("ERROR: Unrecognized employee position: " + office.employees[i].pos); console.log("ERROR: Unrecognized employee position: " + office.employees[i].pos);
break; break;
@ -3969,19 +4120,25 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
industryEmployeeManagementUI.appendChild(createElement("br", {})); industryEmployeeManagementUI.appendChild(createElement("br", {}));
//General display of employee information (avg morale, avg energy, etc.) //General display of employee information (avg morale, avg energy, etc.)
industryEmployeeInfo = createElement("p", {margin:"4px", padding:"4px"});
industryEmployeeManagementUI.appendChild(industryEmployeeInfo); industryEmployeeManagementUI.appendChild(industryEmployeeInfo);
industryEmployeeManagementUI.appendChild(createElement("br", {})); industryEmployeeManagementUI.appendChild(createElement("br", {}));
var positions = [EmployeePositions.Operations, EmployeePositions.Engineer, var positions = [EmployeePositions.Operations, EmployeePositions.Engineer,
EmployeePositions.Business, EmployeePositions.Management, EmployeePositions.Business, EmployeePositions.Management,
EmployeePositions.RandD]; EmployeePositions.RandD, EmployeePositions.Training];
var counts = [opCount, engCount, busCount, mgmtCount, rndCount]; var descriptions = ["Manages supply chain operations. Improves production.", //Operations
"Develops and maintains products and production systems. Improves production.", //Engineer
"Handles sales and finances. Improves sales.", //Business
"Leads and oversees employees and office operations. Improves production.", //Management
"Research new innovative ways to improve the company. Generates Scientific Research", //RandD
"Set employee to training, which will increase some of their stats. Employees in training do not affect any company operations."] //Training
var counts = [opCount, engCount, busCount, mgmtCount, rndCount, trainingCount];
for (var i = 0; i < positions.length; ++i) { for (var i = 0; i < positions.length; ++i) {
(function(corp, i) { (function(corp, i) {
var info = createElement("h2", { var info = createElement("h2", {
display:"inline-block", width:"40%", display:"inline-block", width:"40%", fontSize:"15px",
innerText: positions[i] + "(" + counts[i] + ")" innerText: positions[i] + "(" + counts[i] + ")",
tooltipleft: descriptions[i]
}); });
var plusBtn = createElement("a", { var plusBtn = createElement("a", {
class: unassignedCount > 0 ? "a-link-button" : "a-link-button-inactive", class: unassignedCount > 0 ? "a-link-button" : "a-link-button-inactive",
@ -4040,13 +4197,30 @@ Corporation.prototype.updateDivisionContent = function(division) {
console.log("ERROR: Invalid 'division' argument in Corporation.updateDivisionContent"); console.log("ERROR: Invalid 'division' argument in Corporation.updateDivisionContent");
return; return;
} }
var vechain = (this.unlockUpgrades[4] === 1);
//Industry Overview Text //Industry Overview Text
var profit = division.lastCycleRevenue.minus(division.lastCycleExpenses).toNumber(), var profit = division.lastCycleRevenue.minus(division.lastCycleExpenses).toNumber(),
profitStr = profit >= 0 ? numeral(profit).format("$0.000a") : "-" + numeral(-1 * profit).format("$0.000a"); profitStr = profit >= 0 ? numeral(profit).format("$0.000a") : "-" + numeral(-1 * profit).format("$0.000a");
var advertisingInfo = "";
if (vechain) {
var advertisingFactors = division.getAdvertisingFactors();
var awarenessFac = advertisingFactors[1];
var popularityFac = advertisingFactors[2];
var ratioFac = advertisingFactors[3];
var totalAdvertisingFac = advertisingFactors[0];
advertisingInfo =
"<p class='tooltip'>Advertising Multiplier: x" + formatNumber(totalAdvertisingFac, 3) +
"<span class='tooltiptext' style='font-size:12px'>Total multiplier for this industry's sales due to its awareness and popularity<br>" +
"Awareness Bonus: x" + formatNumber(awarenessFac, 3) + "<br>" +
"Popularity Bonus: x" + formatNumber(popularityFac, 3) + "<br>" +
"Ratio Multiplier: x" + formatNumber(ratioFac, 3) + "</span></p><br>"
}
industryOverviewText.innerHTML = industryOverviewText.innerHTML =
"Industry: " + division.type + "<br><br>" + "Industry: " + division.type + "<br><br>" +
"Awareness: " + formatNumber(division.awareness, 3) + "<br>" + "Awareness: " + formatNumber(division.awareness, 3) + "<br>" +
"Popularity: " + formatNumber(division.popularity, 3) + "<br><br>" + "Popularity: " + formatNumber(division.popularity, 3) + "<br>" +
advertisingInfo + "<br>" +
"Revenue: " + numeral(division.lastCycleRevenue.toNumber()).format("$0.000a") + " / s<br>" + "Revenue: " + numeral(division.lastCycleRevenue.toNumber()).format("$0.000a") + " / s<br>" +
"Expenses: " + numeral(division.lastCycleExpenses.toNumber()).format("$0.000a") + " /s<br>" + "Expenses: " + numeral(division.lastCycleExpenses.toNumber()).format("$0.000a") + " /s<br>" +
"Profit: " + profitStr + " / s<br><br>" + "Profit: " + profitStr + " / s<br><br>" +
@ -4065,11 +4239,13 @@ Corporation.prototype.updateDivisionContent = function(division) {
"Size: " + office.employees.length + " / " + office.size + " employees"; "Size: " + office.employees.length + " / " + office.size + " employees";
if (office.employees.length >= office.size) { if (office.employees.length >= office.size) {
industryEmployeeHireButton.className = "a-link-button-inactive"; industryEmployeeHireButton.className = "a-link-button-inactive";
industryEmployeeAutohireButton.className = "a-link-button-inactive tooltip";
} else { } else {
industryEmployeeHireButton.className = "a-link-button"; industryEmployeeHireButton.className = "a-link-button";
industryEmployeeAutohireButton.className = "a-link-button tooltip";
} }
if (!empManualAssignmentModeActive) { //Employee Overview stats
//Calculate average morale, happiness, and energy //Calculate average morale, happiness, and energy
var totalMorale = 0, totalHappiness = 0, totalEnergy = 0, var totalMorale = 0, totalHappiness = 0, totalEnergy = 0,
avgMorale = 0, avgHappiness = 0, avgEnergy = 0; avgMorale = 0, avgHappiness = 0, avgEnergy = 0;
@ -4087,9 +4263,28 @@ Corporation.prototype.updateDivisionContent = function(division) {
"Avg Employee Morale: " + formatNumber(avgMorale, 3) + "<br>" + "Avg Employee Morale: " + formatNumber(avgMorale, 3) + "<br>" +
"Avg Employee Happiness: " + formatNumber(avgHappiness, 3) + "<br>" + "Avg Employee Happiness: " + formatNumber(avgHappiness, 3) + "<br>" +
"Avg Employee Energy: " + formatNumber(avgEnergy, 3); "Avg Employee Energy: " + formatNumber(avgEnergy, 3);
if (vechain) { //VeChain - Statistics
industryEmployeeInfo.appendChild(createElement("br", {}));
industryEmployeeInfo.appendChild(createElement("p", {
innerText:"Material Production: " + formatNumber(division.getOfficeProductivity(office), 3),
tooltip: "The base amount of material this office can produce. Does not include " +
"production multipliers from upgrades and materials. This value is based off " +
"the productivity of your Operations, Engineering, and Management employees"
}));
industryEmployeeInfo.appendChild(createElement("br", {}));
industryEmployeeInfo.appendChild(createElement("p", {
innerText:"Product Production: " + formatNumber(division.getOfficeProductivity(office, {forProduct:true}), 3),
tooltip: "The base amount of any given Product this office can produce. Does not include " +
"production multipliers from upgrades and materials. This value is based off " +
"the productivity of your Operations, Engineering, and Management employees"
}));
industryEmployeeInfo.appendChild(createElement("br", {}));
industryEmployeeInfo.appendChild(createElement("p", {
innerText: "Business Multiplier: x" + formatNumber(division.getBusinessFactor(office), 3),
tooltip: "The effect this office's 'Business' employees has on boosting sales"
}));
} }
//Warehouse //Warehouse
var warehouse = division.warehouses[currentCityUi]; var warehouse = division.warehouses[currentCityUi];
if (warehouse instanceof Warehouse) { if (warehouse instanceof Warehouse) {
@ -4140,8 +4335,10 @@ Corporation.prototype.clearUI = function() {
industryEmployeePanel = null; industryEmployeePanel = null;
industryEmployeeText = null; industryEmployeeText = null;
industryEmployeeHireButton = null; industryEmployeeHireButton = null;
industryEmployeeAutohireButton = null;
industryEmployeeManagementUI = null; industryEmployeeManagementUI = null;
industryEmployeeInfo = null; industryEmployeeInfo = null;
industryIndividualEmployeeInfo = null;
industryOfficeUpgradeSizeButton = null; industryOfficeUpgradeSizeButton = null;

@ -1,5 +1,5 @@
let CONSTANTS = { let CONSTANTS = {
Version: "0.34.4", Version: "0.34.5",
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience //Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
//and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then //and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
@ -380,9 +380,9 @@ let CONSTANTS = {
"the execution of a script is when it saves/loads. </strong><br><br>", "the execution of a script is when it saves/loads. </strong><br><br>",
TutorialNetscriptText: "Netscript is a programming language implemented for this game. The language has " + TutorialNetscriptText: "Netscript is a programming language implemented for this game. The language has " +
"your basic programming constructs and several built-in commands that are used to hack. <br><br>" + "your basic programming constructs and several built-in commands that are used to hack. <br><br>" +
"<u><h1>Official Wiki and Documentation</h1></u><br>" + "<u><h1>Official Documentation</h1></u><br>" +
"<a href='https://bitburner.wikia.com/wiki/Netscript' target='_blank'>Check out Bitburner's wiki for the official Netscript documentation</a>" + "<a href='https://bitburner.readthedocs.io/en/latest/index.html' target='_blank'>Check out Bitburner's official Netscript documentation</a>" +
". The wiki documentation will contain more details and " + ". This official documentation will contain more details and " +
"code examples than this documentation page. Also, it can be opened up in another tab/window for convenience!<br><br>" + "code examples than this documentation page. Also, it can be opened up in another tab/window for convenience!<br><br>" +
"<u><h1> Variables and data types </h1></u><br>" + "<u><h1> Variables and data types </h1></u><br>" +
"The following data types are supported by Netscript: <br>" + "The following data types are supported by Netscript: <br>" +
@ -440,13 +440,10 @@ let CONSTANTS = {
"either the IP or hostname of the server you want to hack. The runtime for this command depends on your hacking level and the target server's security level. " + "either the IP or hostname of the server you want to hack. The runtime for this command depends on your hacking level and the target server's security level. " +
" A script can hack a server from anywhere. It does not need to be running on the same server to hack that server. " + " 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 " + "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. Returns true if the hack is successful and " + "a server will raise that server's security level by 0.002. Returns the amount of money stolen if the hack is successful and " +
"false otherwise. <br>" + "0 if the hack fails. <br>" +
"Examples: hack('foodnstuff'); or hack('148.192.0.12');<br><br>" + "Examples: hack('foodnstuff'); or hack('148.192.0.12');<br><br>" +
"<i><u>sleep(n, log=true)</u></i><br>Suspends the script for n milliseconds. The second argument is an optional boolean that indicates " + "<i><u>sleep(n)</u></i><br>Suspends the script for n milliseconds.<br>Example: sleep(5000);<br><br>" +
"whether or not the function should log the sleep action. If this argument is true, then calling this function will write " +
"'Sleeping for N milliseconds' to the script's logs. If it's false, then this function will not log anything. " +
"If this argument is not specified then it will be true by default. <br>Example: sleep(5000);<br><br>" +
"<i><u>grow(hostname/ip)</u></i><br>Use your hacking skills to increase the amount of money available on a server. The argument passed in " + "<i><u>grow(hostname/ip)</u></i><br>Use your hacking skills to increase the amount of money available on a server. The argument passed in " +
"must be a string with either the IP or hostname of the target server. The runtime for this command depends on your hacking level and the target server's security level. " + "must be a string with either the IP or hostname of the target 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 " + "When grow() completes, the money available on a target server will be increased by a certain, fixed percentage. This percentage " +
@ -466,6 +463,13 @@ let CONSTANTS = {
"<i><u>print(x)</u></i><br>Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command ). <br><br>" + "<i><u>print(x)</u></i><br>Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command ). <br><br>" +
"<i><u>tprint(x)</u></i><br>Prints a value or a variable to the Terminal<br><br>" + "<i><u>tprint(x)</u></i><br>Prints a value or a variable to the Terminal<br><br>" +
"<i><u>clearLog()</u></i><br>Clears the script's logs. <br><br>" + "<i><u>clearLog()</u></i><br>Clears the script's logs. <br><br>" +
"<i><u>disableLog(fn)</u></i><br>Disables logging for the given function. Logging can be disabled for every function " +
"by passing 'ALL' as an argument.<br><br>" +
"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.<br><br>" +
"Notable functions that cannot have their logs disabled: run, exec, exit<br><br>" +
"<i><u>enableLog(fn)</u></i><br>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')<br><br>" +
"<i><u>scan(hostname/ip, [hostnames=true])</u></i><br>Returns an array containing the hostnames or IPs of all servers that are one node away from the specified server. " + "<i><u>scan(hostname/ip, [hostnames=true])</u></i><br>Returns an array containing the hostnames or IPs of all servers that are one node away from the specified server. " +
"The argument must be a string containing the IP or hostname of the target server. The second argument is a boolean that specifies whether " + "The argument must be a string containing the IP or hostname of the target server. The second argument is a boolean that specifies whether " +
"the hostnames or IPs of the scanned servers should be output. If it is true then hostnames will be returned, and if false then IP addresses will. " + "the hostnames or IPs of the scanned servers should be output. If it is true then hostnames will be returned, and if false then IP addresses will. " +
@ -527,7 +531,7 @@ let CONSTANTS = {
"If you are trying to kill a script named 'foo.script' on the current server that was ran with the arguments 1 and 'foodnstuff', use this:<br><br>" + "If you are trying to kill a script named 'foo.script' on the current server that was ran with the arguments 1 and 'foodnstuff', use this:<br><br>" +
"kill('foo.script', getHostname(), 1, 'foodnstuff');<br><br>" + "kill('foo.script', getHostname(), 1, 'foodnstuff');<br><br>" +
"<i><u>killall(hostname/ip)</u></i><br>Kills all running scripts on the specified server. This function takes a single argument which " + "<i><u>killall(hostname/ip)</u></i><br>Kills all running scripts on the specified server. This function takes a single argument which " +
"must be a string containing the hostname or IP of the target server. This function will always return true. <br><br>" + "must be a string containing the hostname or IP of the target server. This function returns true if any scripts were killed, and false otherwise.<br><br>" +
"<i><u>exit()</u></i><br>Terminates the script immediately<br><br>" + "<i><u>exit()</u></i><br>Terminates the script immediately<br><br>" +
"<i><u>scp(script, [source], destination)</u></i><br>Copies a script or literature (.lit) file to another server. The first argument is a string with " + "<i><u>scp(script, [source], destination)</u></i><br>Copies a script or literature (.lit) file to another server. The first argument is a string with " +
"the filename of the script or literature file " + "the filename of the script or literature file " +
@ -651,7 +655,6 @@ let CONSTANTS = {
"<i><u>getPurchasedServers([hostname=true])</u></i><br>Returns an array with either the hostname or IPs of all of the servers you " + "<i><u>getPurchasedServers([hostname=true])</u></i><br>Returns an array with either the hostname or IPs of all of the servers you " +
"have purchased. It takes an optional parameter specifying whether the hostname or IP addresses will be returned. If this " + "have purchased. It takes an optional parameter specifying whether the hostname or IP addresses will be returned. If this " +
"parameter is not specified, it is true by default and hostnames will be returned<br><br>" + "parameter is not specified, it is true by default and hostnames will be returned<br><br>" +
"<i><u>round(n)</u></i><br>Rounds the number n to the nearest integer. If the argument passed in is not a number, then the function will return 0.<br><br>" +
"<i><u>write(port/fn, data='', mode='a')</u></i><br>This function can be used to either write data to a port or to a text file (.txt).<br><br>" + "<i><u>write(port/fn, data='', mode='a')</u></i><br>This function can be used to either write data to a port or to a text file (.txt).<br><br>" +
"If the first argument is a number between 1 and 10, then it specifies a port and this function will write data to a port. If the second " + "If the first argument is a number between 1 and 10, then it specifies a port and this function will write data to a port. If the second " +
"argument is not specified then it will write an empty string to the port. The third argument, mode, is not used when writing data to a port.<br><br>" + "argument is not specified then it will write an empty string to the port. The third argument, mode, is not used when writing data to a port.<br><br>" +
@ -667,6 +670,9 @@ let CONSTANTS = {
"then the string 'NULL PORT DATA' will be returned.<br><br>" + "then the string 'NULL PORT DATA' will be returned.<br><br>" +
"If the first argument is a string, then it specifies the name of a text file and this function will return the data in the " + "If the first argument is a string, then it specifies the name of a text file 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<br><br>" + "specified text file. If the text file does not exist, an empty string will be returned<br><br>" +
"<i><u>peek(port)</u></i><br>This function is used to peek data from a port. It returns the first element from the specified " +
"Netscript Port without removing that element. If the port is empty, then the string 'NULL PORT DATA' will be returned.<br><br>" +
"The argument must be an integer between 1 and 10.<br><br>" +
"<i><u>clear(port/fn)</u></i><br>This function is used to clear a Netscript Port or a text file.<br><br>" + "<i><u>clear(port/fn)</u></i><br>This function is used to clear a Netscript Port or a text file.<br><br>" +
"It takes a single argument. If this argument is a number between 1 and 10, then it specifies a port and will clear it (deleting all data from it). " + "It takes a single argument. If this argument is a number between 1 and 10, then it specifies a port and will clear it (deleting all data from it). " +
"If the argument is a string, then it specifies the name of a text file (.txt) and will clear the text file so that it is empty.<br><br>" + "If the argument is a string, then it specifies the name of a text file (.txt) and will clear the text file so that it is empty.<br><br>" +
@ -1129,26 +1135,38 @@ let CONSTANTS = {
"World Stock Exchange account and TIX API Access<br>", "World Stock Exchange account and TIX API Access<br>",
LatestUpdate: LatestUpdate:
"v0.34.4<br>" +
"-Added several new features to Gang UI to make it easier to manage your Gang.<br>" +
"-Changed the Gang Member upgrade mechanic. Now, rather than only being able to have " +
"one weapon/armor/vehicle/etc., you can purchase all the upgrades for each Gang member " +
"and their multipliers will stack. To balance this out, the effects (AKA multipliers) of each Gang member upgrade " +
"were reduced.<br>" +
"-Added a new script editor option: Max Error Count. This affects how many approximate lines the script editor will " +
"process (JSHint) for common errors. Increase this option can affect performance<br>" +
"-Game theme colors (set using 'theme' Terminal command) are now saved when re-opening the game<br>" +
"-'download' Terminal command now works on scripts<br>" +
"-Added stopAction() Singularity function and the spawn() Netscript function<br>" +
"-The 'Purchase Augmentations' UI screen will now tell you if you need a certain prerequisite for Augmentations.<br>" +
"-Augmentations with prerequisites can now be purchased as long as their prerequisites are puchased (" +
"before, you had to actually install the prerequisites before being able to purchase)<br><br>" +
"v0.34.5<br>" + "v0.34.5<br>" +
"-Corporation Management Changes:<br>" +
"---Market Research unlocks are now cheaper<br>" +
"---New 'VeChain' upgrade: displays useful statistics about Corporation<br>" +
"---Corporation cycles are processed 25% faster<br>" +
"---Corporation valuation was lowered by ~10% (this affects stock price and investments)<br>" +
"---Rebalanced the effects of advertising. Should now be more effective for every Industry<br>" +
"---Fixed several bugs/exploits involving selling and buying back stock shares<br>" +
"---You will now receive a Corporation Handbook (.lit file) when starting out BitNode-3. It contains a brief guide to help you get started. " +
"This same handbook can be viewed from the Corporation management screen<br>" +
"---Slightly decreased the amount by which a Product's sell price can be marked up<br>" +
"---Employees can now be assigned to a 'Training' task, during which they will slowly increase several of their stats<br>" +
"-Hopefully fixed an exploit with Array.forEach(). If there are any issues with using forEach, let me know<br>" +
"-Arguments passed into a script are now passed by value. This means modifying the 'args' array in a script " +
"should no longer cause issues<br>" +
"-Scripts executed programatically (via run(), exec(), etc.) will now fail if null/undefined is passed in " +
"as an argument<br>" +
"-Added peek() Netscript function<br>" +
"-killall() Netscript function now returns true if any scripts were killed, and false otherwise.<br>" +
"-hack() Netscript function now returns the amount of money gained for successful hacks, and 0 for failed hacks<br>" +
"-scp Terminal command and Netscript function now work for txt files<br>" +
"-Changes courtesy of Wraithan:<br>" + "-Changes courtesy of Wraithan:<br>" +
"---Text files are now displayed using 'pre' rather than 'p' elements when using the 'cat' Terminal command. " + "---Text files are now displayed using 'pre' rather than 'p' elements when using the 'cat' Terminal command. " +
"This means tabs are retained and lines don't automatically wrap<br>" + "This means tabs are retained and lines don't automatically wrap<br>" +
"---ls() Netscript function now returns text files as well<br>" "---ls() Netscript function now returns text files as well<br>" +
"-Removed round() Netscript function, since you can just use Math.round() instead<br>" +
"-Added disableLog() and enableLog() Netscript functions<br>" +
"-Removed the 'log' argument from sleep(), since you can now use the new disableLog function<br>" +
"-'Netscript Documentation' button on script editor now points to new readthedocs documentation rather than wiki<br>" +
"-When working for a faction, your current faction reputation is now displayed<br>" +
"-Bug Fix: Hacking Missions should no longer break when dragging an existing connection to another Node<br>" +
"-Bug Fix: Fixed RAM usage of getNextHacknetNodeCost() (is not 1.5GB instead of 4GB)<br>"
} }
export {CONSTANTS}; export {CONSTANTS};

@ -4,7 +4,7 @@ let TerminalHelpText =
'alias [-g] [name="value"] Create or display Terminal aliases<br>' + 'alias [-g] [name="value"] Create or display Terminal aliases<br>' +
"analyze Get information about the current machine <br>" + "analyze Get information about the current machine <br>" +
"buy [-l/program] Purchase a program through the Dark Web<br>" + "buy [-l/program] Purchase a program through the Dark Web<br>" +
"cat [file] Display a .msg or .lit file<br>" + "cat [file] Display a .msg, .lit, or .txt file<br>" +
"check [script] [args...] Print a script's logs to Terminal<br>" + "check [script] [args...] Print a script's logs to Terminal<br>" +
"clear Clear all text on the terminal <br>" + "clear Clear all text on the terminal <br>" +
"cls See 'clear' command <br>" + "cls See 'clear' command <br>" +
@ -27,7 +27,7 @@ let TerminalHelpText =
"run [name] [-t] [n] [args...] Execute a program or script<br>" + "run [name] [-t] [n] [args...] Execute a program or script<br>" +
"scan Prints all immediately-available network connections<br>" + "scan Prints all immediately-available network connections<br>" +
"scan-analyze [d] [-a] Prints info for all servers up to <i>d</i> nodes away<br>" + "scan-analyze [d] [-a] Prints info for all servers up to <i>d</i> nodes away<br>" +
"scp [file] [server] Copies a script or .lit file to a destination server<br>" + "scp [file] [server] Copies a file to a destination server<br>" +
"sudov Shows whether you have root access on this computer<br>" + "sudov Shows whether you have root access on this computer<br>" +
"tail [script] [args...] Displays dynamic logs for the specified script<br>" + "tail [script] [args...] Displays dynamic logs for the specified script<br>" +
"theme [preset] | bg txt hlgt Change the color scheme of the UI<br>" + "theme [preset] | bg txt hlgt Change the color scheme of the UI<br>" +
@ -65,10 +65,10 @@ let HelpTexts = {
"dark web to the Terminal, as well as their costs.<br><br>" + "dark web to the Terminal, as well as their costs.<br><br>" +
"Otherwise, the name of the program must be passed in as a parameter. This is name is NOT case-sensitive.", "Otherwise, the name of the program must be passed in as a parameter. This is name is NOT case-sensitive.",
cat: "cat [file]<br>" + cat: "cat [file]<br>" +
"Display message files, which are files ending with the '.msg' extension, or a literature file, which " + "Display message (.msg), literature (.lit), or text (.txt) files. Examples:<br><br>" +
"are files ending with the '.lit' extension. Examples:<br><br>" +
"cat j1.msg<br>" + "cat j1.msg<br>" +
"cat foo.lit", "cat foo.lit<br>" +
"cat servers.txt",
check: "check [script name] [args...]<br>" + check: "check [script name] [args...]<br>" +
"Print the logs of the script specified by the script name and arguments to the Terminal. Each argument must be separated by " + "Print the logs of the script specified by the script name and arguments to the Terminal. Each argument must be separated by " +
"a space. Remember that a running script is uniquely " + "a space. Remember that a running script is uniquely " +
@ -171,7 +171,8 @@ let HelpTexts = {
"-a flag at the end of the command if you would like to enable that.", "-a flag at the end of the command if you would like to enable that.",
scp: "scp [filename] [target server]<br>" + scp: "scp [filename] [target server]<br>" +
"Copies the specified file from the current server to the target server. " + "Copies the specified file from the current server to the target server. " +
"This command only works for script files (.script extension) and literature files (.lit extension). " + "This command only works for script files (.script extension), literature files (.lit extension), " +
"and text files (.txt extension). " +
"The second argument passed in must be the hostname or IP of the target server.", "The second argument passed in must be the hostname or IP of the target server.",
sudov: "sudov<br>" + sudov: "sudov<br>" +
"Prints whether or not you have root access to the current machine", "Prints whether or not you have root access to the current machine",

@ -41,7 +41,39 @@ function initLiterature() {
title = "The Complete Handbook for Creating a Successful Corporation"; title = "The Complete Handbook for Creating a Successful Corporation";
fn = "corporation-management-handbook.lit"; fn = "corporation-management-handbook.lit";
txt = "This is a brief collection of tips/pointers on how to successfully start and manage a Corporation.<br><br>" + txt = "<u>Getting Started with Corporations</u><br>" +
"To get started, visit the City Hall in Sector-12 in order to create a Corporation. This requires " +
"$150b of your own money, but this $150b will get put into your Corporation's funds. " +
"After creating your Corporation, you will see it listed as one of the locations in the city. Click on " +
"your Corporation in order to manage it.<br><br>" +
"Your Corporation can have many different divisions, each in a different Industry. There are many different " +
"types of Industries, each with different properties. To create your first division, click the " +
"'Expand into new Industry' button at the top of the management UI. The Agriculture " +
"and Software industries are recommended for your first division.<br><br>" +
"The first thing you'll need to do is hire some employees. Employees can be assigned to five different positions. " +
"Each position has a different effect on various aspects of your Corporation. It is recommended to have at least " +
"one employee at each position.<br><br>" +
"Each industry uses some combination of Materials in order to produce other Materials and/or create Products. " +
"Specific information about this is displayed in each of your divisions' UI.<br><br>" +
"Products are special, industry-specific objects. They are different than Materials because you " +
"must manually choose to develop them, and you can choose to develop any number of Products. Developing " +
"a Product takes time, but a Product typically generates significantly more revenue than any Material. " +
"Not all industries allow you to create Products. To create a Product, look for a button " +
"in the top-left panel of the division UI (e.g. For the Software Industry, the button says 'Develop Software').<br><br>" +
"To get your supply chain system started, " +
"purchase the Materials that your industry needs to produce other Materials/Products. This can be done " +
"by clicking the 'Buy' button next to the corresponding Material(s). After you have the required Materials, " +
"you will immediately start production. The amount of Materials/Products you produce is based on a variety of factors, " +
"one of which is your employees and their productivity.<br><br>" +
"Once you start producing Materials/Products, you can sell them in order to start earning revenue. This can be done " +
"by clicking the 'Sell' button next to the corresponding Material or Product. The amount of Material/Product you sell is dependent " +
"on a wide variety of different factors.<br><br>" +
"These are the basics of getting your Corporation up and running! Now, you can start purchasing upgrades to improve " +
"your bottom line. If you need money, consider looking for seed investors, who will give you money in exchange for stock shares. " +
"Otherwise, once you feel you are ready, take your Corporation public! Once your Corporation goes public, you can no longer " +
"find investors. Instead, your Corporation will be publicly traded and its stock price will change based on how well " +
"it's performing financially. You can then sell your stock shares in order to make money.<br><br>" +
"<u>Tips/Pointers</u><br>" +
"-Purchasing Hardware, Robots, AI Cores, and Real Estate can potentially increase your production. " + "-Purchasing Hardware, Robots, AI Cores, and Real Estate can potentially increase your production. " +
"The effects of these depend on what industry you are in.<br><br>" + "The effects of these depend on what industry you are in.<br><br>" +
"-In order to optimize your production, you will need a good balance of Operators, Managers, and Engineers<br><br>" + "-In order to optimize your production, you will need a good balance of Operators, Managers, and Engineers<br><br>" +
@ -51,7 +83,9 @@ function initLiterature() {
"-Tech is important, but don't neglect sales! Having several Businessmen can boost your sales and your bottom line.<br><br>" + "-Tech is important, but don't neglect sales! Having several Businessmen can boost your sales and your bottom line.<br><br>" +
"-Don't forget to advertise your company. You won't have any business if nobody knows you.<br><br>" + "-Don't forget to advertise your company. You won't have any business if nobody knows you.<br><br>" +
"-Having company awareness is great, but what's really important is your company's popularity. Try to keep " + "-Having company awareness is great, but what's really important is your company's popularity. Try to keep " +
"your popularity as high as possible to see the biggest benefit for your sales<br><br>"; "your popularity as high as possible to see the biggest benefit for your sales<br><br>" +
"-Remember, you need to spend money to make money!<br><br>" +
"-Corporations do not reset when installing Augmentations, but they do reset when destroying a BitNode";
Literatures[fn] = new Literature(title, fn, txt); Literatures[fn] = new Literature(title, fn, txt);
title = "A Green Tomorrow"; title = "A Green Tomorrow";

@ -42,7 +42,7 @@ function showMessage(msg) {
var txt = "Message received from unknown sender: <br><br>" + var txt = "Message received from unknown sender: <br><br>" +
"<i>" + msg.msg + "</i><br><br>" + "<i>" + msg.msg + "</i><br><br>" +
"This message was saved as " + msg.filename + " onto your home computer."; "This message was saved as " + msg.filename + " onto your home computer.";
dialogBoxCreate(txt, true); dialogBoxCreate(txt);
} }
//Adds a message to a server //Adds a message to a server

@ -1162,14 +1162,16 @@ HackingMission.prototype.processNode = function(nodeObj, numCycles=1) {
var targetNode = null, def, atk; var targetNode = null, def, atk;
if (nodeObj.conn) { if (nodeObj.conn) {
var targetNode; if (nodeObj.conn.target != null) {
if (nodeObj.conn.target) {
targetNode = this.getNodeFromElement(nodeObj.conn.target); targetNode = this.getNodeFromElement(nodeObj.conn.target);
} else { } else {
targetNode = this.getNodeFromElement(nodeObj.conn.targetId); targetNode = this.getNodeFromElement(nodeObj.conn.targetId);
} }
if (targetNode.plyrCtrl) { if (targetNode == null) {
//Player is in the middle of dragging the connection,
//so the target node is null. Do nothing here
} else if (targetNode.plyrCtrl) {
def = this.playerDef; def = this.playerDef;
atk = this.enemyAtk; atk = this.enemyAtk;
} else if (targetNode.enmyCtrl) { } else if (targetNode.enmyCtrl) {
@ -1186,17 +1188,20 @@ HackingMission.prototype.processNode = function(nodeObj, numCycles=1) {
var enmyHacking = this.difficulty * CONSTANTS.HackingMissionDifficultyToHacking; var enmyHacking = this.difficulty * CONSTANTS.HackingMissionDifficultyToHacking;
switch(nodeObj.action) { switch(nodeObj.action) {
case NodeActions.Attack: case NodeActions.Attack:
if (targetNode == null) {break;}
if (nodeObj.conn == null) {break;} if (nodeObj.conn == null) {break;}
var dmg = this.calculateAttackDamage(atk, def, plyr ? Player.hacking_skill : enmyHacking); var dmg = this.calculateAttackDamage(atk, def, plyr ? Player.hacking_skill : enmyHacking);
targetNode.hp -= (dmg/5 * numCycles); targetNode.hp -= (dmg/5 * numCycles);
break; break;
case NodeActions.Scan: case NodeActions.Scan:
if (targetNode == null) {break;}
if (nodeObj.conn == null) {break;} if (nodeObj.conn == null) {break;}
var eff = this.calculateScanEffect(atk, def, plyr ? Player.hacking_skill : enmyHacking); var eff = this.calculateScanEffect(atk, def, plyr ? Player.hacking_skill : enmyHacking);
targetNode.def -= (eff/5 * numCycles); targetNode.def -= (eff/5 * numCycles);
calcStats = true; calcStats = true;
break; break;
case NodeActions.Weaken: case NodeActions.Weaken:
if (targetNode == null) {break;}
if (nodeObj.conn == null) {break;} if (nodeObj.conn == null) {break;}
var eff = this.calculateWeakenEffect(atk, def, plyr ? Player.hacking_skill : enmyHacking); var eff = this.calculateWeakenEffect(atk, def, plyr ? Player.hacking_skill : enmyHacking);
targetNode.atk -= (eff/5 * numCycles); targetNode.atk -= (eff/5 * numCycles);

@ -75,19 +75,6 @@ Environment.prototype = {
} }
return res[idx[idx.length-1]] = value; return res[idx[idx.length-1]] = value;
}, },
/*
setArrayElement: function(name, idx, value) {
var scope = this.lookup(name);
if (!scope && this.parent) {
console.log("Here");
throw new Error("Undefined variable " + name);
}
var arr = (scope || this).vars[name];
if (!(arr.constructor === Array || arr instanceof Array)) {
throw new Error("Variable is not an array: " + name);
}
return (scope || this).vars[name][idx] = value;
},*/
//Creates (or overwrites) a variable in the current scope //Creates (or overwrites) a variable in the current scope
def: function(name, value) { def: function(name, value) {

@ -27,7 +27,6 @@ Promise.config({
* Returns a promise * Returns a promise
*/ */
function evaluate(exp, workerScript) { function evaluate(exp, workerScript) {
/* return new Promise(function(resolve, reject) {*/
return Promise.delay(Settings.CodeInstructionRunTime).then(function() { return Promise.delay(Settings.CodeInstructionRunTime).then(function() {
var env = workerScript.env; var env = workerScript.env;
if (env.stopFlag) {return Promise.reject(workerScript);} if (env.stopFlag) {return Promise.reject(workerScript);}
@ -139,6 +138,13 @@ function evaluate(exp, workerScript) {
} else if (exp.callee.type == "MemberExpression"){ } else if (exp.callee.type == "MemberExpression"){
return evaluate(exp.callee.object, workerScript).then(function(object) { return evaluate(exp.callee.object, workerScript).then(function(object) {
try { try {
if (func === "NETSCRIPTFOREACH") {
return evaluateForeach(object, args, workerScript).then(function(res) {
return Promise.resolve(res);
}).catch(function(e) {
return Promise.reject(e);
});
}
var res = func.apply(object,args); var res = func.apply(object,args);
return Promise.resolve(res); return Promise.resolve(res);
} catch (e) { } catch (e) {
@ -187,6 +193,9 @@ function evaluate(exp, workerScript) {
if (exp.property.name === "constructor") { if (exp.property.name === "constructor") {
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Illegal usage of constructor() method. If you have your own function named 'constructor', you must re-name it.")); return Promise.reject(makeRuntimeRejectMsg(workerScript, "Illegal usage of constructor() method. If you have your own function named 'constructor', you must re-name it."));
} }
if (object != null && object instanceof Array && exp.property.name === "forEach") {
return "NETSCRIPTFOREACH";
}
try { try {
return Promise.resolve(object[exp.property.name]) return Promise.resolve(object[exp.property.name])
} catch (e) { } catch (e) {
@ -537,35 +546,43 @@ function evaluateFor(exp, workerScript) {
} }
recurse(); recurse();
}); });
/* }
return evaluate(exp.test, workerScript).then(function(resCond) {
if (resCond) { function evaluateForeach(arr, args, workerScript) {
//Execute code (body), update, and then recurse console.log("evaluateForeach called");
return evaluate(exp.body, workerScript).then(function(resCode) { if (!(arr instanceof Array)) {
return evaluate(exp.update, workerScript); return Promise.reject("Invalid array passed into forEach");
}).catch(function(e) { }
if (e == "CONTINUESTATEMENT" || if (!(args instanceof Array) && args.length != 1) {
(e instanceof WorkerScript && e.errorMessage == "CONTINUESTATEMENT")) { return Promise.reject("Invalid argument passed into forEach");
//Continue statement, recurse to next iteration }
return evaluate(exp.update, workerScript).then(function(resPostloop) { var func = args[0];
return evaluateFor(exp, workerScript); if (typeof func !== "function") {
}).then(function(foo) { return Promise.reject("Invalid function passed into forEach");
return Promise.resolve("endForLoop"); }
}).catch(function(e) { console.log(func);
return new Promise(function(resolve, reject) {
//Don't return a promise so the promise chain is broken on each recursion
function recurse(i) {
console.log("recurse() called with i: " + i);
if (i >= arr.length) {
resolve();
} else {
return Promise.delay(Settings.CodeInstructionRunTime).then(function() {
console.log("About to apply function");
var res = func.apply(null, [arr[i]]);
console.log("Applied function");
++i;
Promise.resolve(res).then(function(val) {
recurse(i);
}, reject).catch(function(e) {
return Promise.reject(e); return Promise.reject(e);
}); });
} else {
return Promise.reject(e);
}
}).then(function(resPostloop) {
return evaluateFor(exp, workerScript);
}).then(function(foo) {
return Promise.resolve("endForLoop");
}); });
} else {
return Promise.resolve("endForLoop"); //Doesn't need to resolve to any particular value
} }
});*/ }
recurse(0);
});
} }
function evaluateWhile(exp, workerScript) { function evaluateWhile(exp, workerScript) {
@ -703,6 +720,14 @@ function runScriptFromScript(server, scriptname, args, workerScript, threads=1)
return Promise.resolve(false); return Promise.resolve(false);
} }
//'null/undefined' arguments are not allowed
for (var i = 0; i < args.length; ++i) {
if (args[i] == null) {
workerScript.scriptRef.log("ERROR: Cannot execute a script with null/undefined as an argument");
return Promise.resolve(false);
}
}
//Check if the script exists and if it does run it //Check if the script exists and if it does run it
for (var i = 0; i < server.scripts.length; ++i) { for (var i = 0; i < server.scripts.length; ++i) {
if (server.scripts[i].filename == scriptname) { if (server.scripts[i].filename == scriptname) {

@ -128,7 +128,9 @@ function NetscriptFunctions(workerScript) {
} }
out.push(entry); out.push(entry);
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scan == null) {
workerScript.scriptRef.log('scan() returned ' + server.serversOnNetwork.length + ' connections for ' + server.hostname); workerScript.scriptRef.log('scan() returned ' + server.serversOnNetwork.length + ' connections for ' + server.hostname);
}
return out; return out;
}, },
hack : function(ip){ hack : function(ip){
@ -165,8 +167,9 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, "Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough"); throw makeRuntimeRejectMsg(workerScript, "Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough");
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime.toFixed(3) + " seconds (t=" + threads + ")"); workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime.toFixed(3) + " seconds (t=" + threads + ")");
//console.log("Hacking " + server.hostname + " after " + hackingTime.toString() + " seconds (t=" + threads + ")"); }
return netscriptDelay(hackingTime* 1000, workerScript).then(function() { return netscriptDelay(hackingTime* 1000, workerScript).then(function() {
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
var hackChance = scriptCalculateHackingChance(server); var hackChance = scriptCalculateHackingChance(server);
@ -192,26 +195,28 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.recordHack(server.ip, moneyGained, threads); workerScript.scriptRef.recordHack(server.ip, moneyGained, threads);
Player.gainHackingExp(expGainedOnSuccess); Player.gainHackingExp(expGainedOnSuccess);
workerScript.scriptRef.onlineExpGained += expGainedOnSuccess; workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
//console.log("Script successfully hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp"); if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp (t=" + threads + ")"); workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp (t=" + threads + ")");
}
server.fortify(CONSTANTS.ServerFortifyAmount * threads); server.fortify(CONSTANTS.ServerFortifyAmount * threads);
return Promise.resolve(true); return Promise.resolve(moneyGained);
} else { } else {
//Player only gains 25% exp for failure? TODO Can change this later to balance //Player only gains 25% exp for failure?
Player.gainHackingExp(expGainedOnFailure); Player.gainHackingExp(expGainedOnFailure);
workerScript.scriptRef.onlineExpGained += expGainedOnFailure; workerScript.scriptRef.onlineExpGained += expGainedOnFailure;
//console.log("Script unsuccessful to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " exp"); if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " exp (t=" + threads + ")"); workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " exp (t=" + threads + ")");
return Promise.resolve(false); }
return Promise.resolve(0);
} }
}); });
}, },
sleep : function(time,log=true){ sleep : function(time){
if (workerScript.checkingRam) {return 0;} if (workerScript.checkingRam) {return 0;}
if (time === undefined) { if (time === undefined) {
throw makeRuntimeRejectMsg(workerScript, "sleep() call has incorrect number of arguments. Takes 1 argument"); throw makeRuntimeRejectMsg(workerScript, "sleep() call has incorrect number of arguments. Takes 1 argument");
} }
if (log) { if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sleep == null) {
workerScript.scriptRef.log("Sleeping for " + time + " milliseconds"); workerScript.scriptRef.log("Sleeping for " + time + " milliseconds");
} }
return netscriptDelay(time, workerScript).then(function() { return netscriptDelay(time, workerScript).then(function() {
@ -245,8 +250,9 @@ function NetscriptFunctions(workerScript) {
} }
var growTime = scriptCalculateGrowTime(server); var growTime = scriptCalculateGrowTime(server);
//console.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds") if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds (t=" + threads + ")"); workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds (t=" + threads + ")");
}
return netscriptDelay(growTime, workerScript).then(function() { return netscriptDelay(growTime, workerScript).then(function() {
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
server.moneyAvailable += (1 * threads); //It can be grown even if it has no money server.moneyAvailable += (1 * threads); //It can be grown even if it has no money
@ -256,9 +262,11 @@ function NetscriptFunctions(workerScript) {
if (growthPercentage == 1) { if (growthPercentage == 1) {
expGain = 0; expGain = 0;
} }
workerScript.scriptRef.log("Available money on " + server.hostname + " grown by " if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
+ formatNumber(growthPercentage*100 - 100, 6) + "%. Gained " + workerScript.scriptRef.log("Available money on " + server.hostname + " grown by " +
formatNumber(growthPercentage*100 - 100, 6) + "%. Gained " +
formatNumber(expGain, 4) + " hacking exp (t=" + threads +")"); formatNumber(expGain, 4) + " hacking exp (t=" + threads +")");
}
workerScript.scriptRef.onlineExpGained += expGain; workerScript.scriptRef.onlineExpGained += expGain;
Player.gainHackingExp(expGain); Player.gainHackingExp(expGain);
return Promise.resolve(growthPercentage); return Promise.resolve(growthPercentage);
@ -291,15 +299,19 @@ function NetscriptFunctions(workerScript) {
} }
var weakenTime = scriptCalculateWeakenTime(server); var weakenTime = scriptCalculateWeakenTime(server);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " + workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " +
formatNumber(weakenTime/1000, 3) + " seconds (t=" + threads + ")"); formatNumber(weakenTime/1000, 3) + " seconds (t=" + threads + ")");
}
return netscriptDelay(weakenTime, workerScript).then(function() { return netscriptDelay(weakenTime, workerScript).then(function() {
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
server.weaken(CONSTANTS.ServerWeakenAmount * threads); server.weaken(CONSTANTS.ServerWeakenAmount * threads);
workerScript.scriptRef.recordWeaken(server.ip, threads); workerScript.scriptRef.recordWeaken(server.ip, threads);
var expGain = scriptCalculateExpGain(server) * threads; var expGain = scriptCalculateExpGain(server) * threads;
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
workerScript.scriptRef.log("Server security level on " + server.hostname + " weakened to " + server.hackDifficulty + workerScript.scriptRef.log("Server security level on " + server.hostname + " weakened to " + server.hackDifficulty +
". Gained " + formatNumber(expGain, 4) + " hacking exp (t=" + threads + ")"); ". Gained " + formatNumber(expGain, 4) + " hacking exp (t=" + threads + ")");
}
workerScript.scriptRef.onlineExpGained += expGain; workerScript.scriptRef.onlineExpGained += expGain;
Player.gainHackingExp(expGain); Player.gainHackingExp(expGain);
return Promise.resolve(CONSTANTS.ServerWeakenAmount * threads); return Promise.resolve(CONSTANTS.ServerWeakenAmount * threads);
@ -331,6 +343,16 @@ function NetscriptFunctions(workerScript) {
if (workerScript.checkingRam) {return 0;} if (workerScript.checkingRam) {return 0;}
workerScript.scriptRef.clearLog(); workerScript.scriptRef.clearLog();
}, },
disableLog : function(fn) {
if (workerScript.checkingRam) {return 0;}
workerScript.disableLogs[fn] = true;
workerScript.scriptRef.log("Disabled logging for " + fn);
},
enableLog : function(fn) {
if (workerScript.checkingRam) {return 0;}
delete workerScript.disableLogs[fn];
workerScript.scriptRef.log("Enabled logging for " + fn);
},
nuke : function(ip){ nuke : function(ip){
if (workerScript.checkingRam) { if (workerScript.checkingRam) {
if (workerScript.loadedFns.nuke) { if (workerScript.loadedFns.nuke) {
@ -355,11 +377,15 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, "Not enough ports opened to use NUKE.exe virus"); throw makeRuntimeRejectMsg(workerScript, "Not enough ports opened to use NUKE.exe virus");
} }
if (server.hasAdminRights) { if (server.hasAdminRights) {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.nuke == null) {
workerScript.scriptRef.log("Already have root access to " + server.hostname); workerScript.scriptRef.log("Already have root access to " + server.hostname);
}
} else { } else {
server.hasAdminRights = true; server.hasAdminRights = true;
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.nuke == null) {
workerScript.scriptRef.log("Executed NUKE.exe virus on " + server.hostname + " to gain root access"); workerScript.scriptRef.log("Executed NUKE.exe virus on " + server.hostname + " to gain root access");
} }
}
return true; return true;
}, },
brutessh : function(ip){ brutessh : function(ip){
@ -384,12 +410,16 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, "You do not have the BruteSSH.exe program!"); throw makeRuntimeRejectMsg(workerScript, "You do not have the BruteSSH.exe program!");
} }
if (!server.sshPortOpen) { if (!server.sshPortOpen) {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.brutessh == null) {
workerScript.scriptRef.log("Executed BruteSSH.exe on " + server.hostname + " to open SSH port (22)"); workerScript.scriptRef.log("Executed BruteSSH.exe on " + server.hostname + " to open SSH port (22)");
}
server.sshPortOpen = true; server.sshPortOpen = true;
++server.openPortCount; ++server.openPortCount;
} else { } else {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.brutessh == null) {
workerScript.scriptRef.log("SSH Port (22) already opened on " + server.hostname); workerScript.scriptRef.log("SSH Port (22) already opened on " + server.hostname);
} }
}
return true; return true;
}, },
ftpcrack : function(ip){ ftpcrack : function(ip){
@ -413,12 +443,16 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, "You do not have the FTPCrack.exe program!"); throw makeRuntimeRejectMsg(workerScript, "You do not have the FTPCrack.exe program!");
} }
if (!server.ftpPortOpen) { if (!server.ftpPortOpen) {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.ftpcrack == null) {
workerScript.scriptRef.log("Executed FTPCrack.exe on " + server.hostname + " to open FTP port (21)"); workerScript.scriptRef.log("Executed FTPCrack.exe on " + server.hostname + " to open FTP port (21)");
}
server.ftpPortOpen = true; server.ftpPortOpen = true;
++server.openPortCount; ++server.openPortCount;
} else { } else {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.ftpcrack == null) {
workerScript.scriptRef.log("FTP Port (21) already opened on " + server.hostname); workerScript.scriptRef.log("FTP Port (21) already opened on " + server.hostname);
} }
}
return true; return true;
}, },
relaysmtp : function(ip){ relaysmtp : function(ip){
@ -442,12 +476,16 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, "You do not have the relaySMTP.exe program!"); throw makeRuntimeRejectMsg(workerScript, "You do not have the relaySMTP.exe program!");
} }
if (!server.smtpPortOpen) { if (!server.smtpPortOpen) {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.relaysmtp == null) {
workerScript.scriptRef.log("Executed relaySMTP.exe on " + server.hostname + " to open SMTP port (25)"); workerScript.scriptRef.log("Executed relaySMTP.exe on " + server.hostname + " to open SMTP port (25)");
}
server.smtpPortOpen = true; server.smtpPortOpen = true;
++server.openPortCount; ++server.openPortCount;
} else { } else {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.relaysmtp == null) {
workerScript.scriptRef.log("SMTP Port (25) already opened on " + server.hostname); workerScript.scriptRef.log("SMTP Port (25) already opened on " + server.hostname);
} }
}
return true; return true;
}, },
httpworm : function(ip){ httpworm : function(ip){
@ -471,12 +509,16 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, "You do not have the HTTPWorm.exe program!"); throw makeRuntimeRejectMsg(workerScript, "You do not have the HTTPWorm.exe program!");
} }
if (!server.httpPortOpen) { if (!server.httpPortOpen) {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.httpworm == null) {
workerScript.scriptRef.log("Executed HTTPWorm.exe on " + server.hostname + " to open HTTP port (80)"); workerScript.scriptRef.log("Executed HTTPWorm.exe on " + server.hostname + " to open HTTP port (80)");
}
server.httpPortOpen = true; server.httpPortOpen = true;
++server.openPortCount; ++server.openPortCount;
} else { } else {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.httpworm == null) {
workerScript.scriptRef.log("HTTP Port (80) already opened on " + server.hostname); workerScript.scriptRef.log("HTTP Port (80) already opened on " + server.hostname);
} }
}
return true; return true;
}, },
sqlinject : function(ip){ sqlinject : function(ip){
@ -500,12 +542,16 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, "You do not have the SQLInject.exe program!"); throw makeRuntimeRejectMsg(workerScript, "You do not have the SQLInject.exe program!");
} }
if (!server.sqlPortOpen) { if (!server.sqlPortOpen) {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sqlinject == null) {
workerScript.scriptRef.log("Executed SQLInject.exe on " + server.hostname + " to open SQL port (1433)"); workerScript.scriptRef.log("Executed SQLInject.exe on " + server.hostname + " to open SQL port (1433)");
}
server.sqlPortOpen = true; server.sqlPortOpen = true;
++server.openPortCount; ++server.openPortCount;
} else { } else {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sqlinject == null) {
workerScript.scriptRef.log("SQL Port (1433) already opened on " + server.hostname); workerScript.scriptRef.log("SQL Port (1433) already opened on " + server.hostname);
} }
}
return true; return true;
}, },
run : function(scriptname,threads = 1){ run : function(scriptname,threads = 1){
@ -574,7 +620,9 @@ function NetscriptFunctions(workerScript) {
setTimeout(()=>{ setTimeout(()=>{
NetscriptFunctions(workerScript).run.apply(this, arguments); NetscriptFunctions(workerScript).run.apply(this, arguments);
}, 20000); }, 20000);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.spawn == null) {
workerScript.scriptRef.log("spawn() will execute " + scriptname + " in 20 seconds"); workerScript.scriptRef.log("spawn() will execute " + scriptname + " in 20 seconds");
}
NetscriptFunctions(workerScript).exit(); NetscriptFunctions(workerScript).exit();
}, },
kill : function(filename,ip) { kill : function(filename,ip) {
@ -606,10 +654,14 @@ function NetscriptFunctions(workerScript) {
} }
var res = killWorkerScript(runningScriptObj, server.ip); var res = killWorkerScript(runningScriptObj, server.ip);
if (res) { if (res) {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.kill == null) {
workerScript.scriptRef.log("Killing " + filename + " on " + server.hostname + " with args: " + printArray(argsForKillTarget) + ". May take up to a few minutes for the scripts to die..."); workerScript.scriptRef.log("Killing " + filename + " on " + server.hostname + " with args: " + printArray(argsForKillTarget) + ". May take up to a few minutes for the scripts to die...");
}
return true; return true;
} else { } else {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.kill == null) {
workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + printArray(argsForKillTarget)); workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + printArray(argsForKillTarget));
}
return false; return false;
} }
}, },
@ -631,11 +683,14 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("killall() failed. Invalid IP or hostname passed in: " + ip); workerScript.scriptRef.log("killall() failed. Invalid IP or hostname passed in: " + ip);
throw makeRuntimeRejectMsg(workerScript, "killall() failed. Invalid IP or hostname passed in: " + ip); throw makeRuntimeRejectMsg(workerScript, "killall() failed. Invalid IP or hostname passed in: " + ip);
} }
var scriptsRunning = (server.runningScripts.length > 0);
for (var i = server.runningScripts.length-1; i >= 0; --i) { for (var i = server.runningScripts.length-1; i >= 0; --i) {
killWorkerScript(server.runningScripts[i], server.ip); killWorkerScript(server.runningScripts[i], server.ip);
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.killall == null) {
workerScript.scriptRef.log("killall(): Killing all scripts on " + server.hostname + ". May take a few minutes for the scripts to die"); workerScript.scriptRef.log("killall(): Killing all scripts on " + server.hostname + ". May take a few minutes for the scripts to die");
return true; }
return scriptsRunning;
}, },
exit : function() { exit : function() {
if (workerScript.checkingRam) { if (workerScript.checkingRam) {
@ -678,8 +733,9 @@ function NetscriptFunctions(workerScript) {
}); });
return res; return res;
} }
if (!scriptname.endsWith(".lit") && !scriptname.endsWith(".script")) { if (!scriptname.endsWith(".lit") && !scriptname.endsWith(".script") &&
throw makeRuntimeRejectMsg(workerScript, "Error: scp() only works for .script and .lit files"); !scriptname.endsWith("txt")) {
throw makeRuntimeRejectMsg(workerScript, "Error: scp() does not work with this file type. It only works for .script, .lit, and .txt files");
} }
var destServer, currServ; var destServer, currServ;
@ -718,6 +774,7 @@ function NetscriptFunctions(workerScript) {
for (var i = 0; i < currServ.messages.length; ++i) { for (var i = 0; i < currServ.messages.length; ++i) {
if (!(currServ.messages[i] instanceof Message) && currServ.messages[i] == scriptname) { if (!(currServ.messages[i] instanceof Message) && currServ.messages[i] == scriptname) {
found = true; found = true;
break;
} }
} }
@ -728,12 +785,50 @@ function NetscriptFunctions(workerScript) {
for (var i = 0; i < destServer.messages.length; ++i) { for (var i = 0; i < destServer.messages.length; ++i) {
if (destServer.messages[i] === scriptname) { if (destServer.messages[i] === scriptname) {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname); workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
}
return true; //Already exists return true; //Already exists
} }
} }
destServer.messages.push(scriptname); destServer.messages.push(scriptname);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname); workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
}
return true;
}
//Scp for text files
if (scriptname.endsWith(".txt")) {
var found = false, txtFile;
for (var i = 0; i < currServ.textFiles.length; ++i) {
if (currServ.textFiles[i].fn === scriptname) {
found = true;
txtFile = currServ.textFiles[i];
break;
}
}
if (!found) {
workerScript.scriptRef.log(scriptname + " does not exist. scp() failed");
return false;
}
for (var i = 0; i < destServer.textFiles.length; ++i) {
if (destServer.textFiles[i].fn === scriptname) {
//Overwrite
destServer.textFiles[i].text = txtFile.text;
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
}
return true;
}
}
var newFile = new TextFile(txtFile.fn, txtFile.text);
destServer.textFiles.push(newFile);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
}
return true; return true;
} }
@ -753,8 +848,10 @@ function NetscriptFunctions(workerScript) {
//Overwrite script if it already exists //Overwrite script if it already exists
for (var i = 0; i < destServer.scripts.length; ++i) { for (var i = 0; i < destServer.scripts.length; ++i) {
if (scriptname == destServer.scripts[i].filename) { if (scriptname == destServer.scripts[i].filename) {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
workerScript.scriptRef.log("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and it will be overwritten."); workerScript.scriptRef.log("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and it will be overwritten.");
workerScript.scriptRef.log(scriptname + " overwritten on " + destServer.hostname); workerScript.scriptRef.log(scriptname + " overwritten on " + destServer.hostname);
}
var oldScript = destServer.scripts[i]; var oldScript = destServer.scripts[i];
oldScript.code = sourceScript.code; oldScript.code = sourceScript.code;
oldScript.ramUsage = sourceScript.ramUsage; oldScript.ramUsage = sourceScript.ramUsage;
@ -769,7 +866,9 @@ function NetscriptFunctions(workerScript) {
newScript.ramUsage = sourceScript.ramUsage; newScript.ramUsage = sourceScript.ramUsage;
newScript.server = destServer.ip; newScript.server = destServer.ip;
destServer.scripts.push(newScript); destServer.scripts.push(newScript);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname); workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
}
return true; return true;
}, },
ls : function(ip, grep) { ls : function(ip, grep) {
@ -907,7 +1006,9 @@ function NetscriptFunctions(workerScript) {
} }
} }
Player.updateSkillLevels(); Player.updateSkillLevels();
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getHackingLevel == null) {
workerScript.scriptRef.log("getHackingLevel() returned " + Player.hacking_skill); workerScript.scriptRef.log("getHackingLevel() returned " + Player.hacking_skill);
}
return Player.hacking_skill; return Player.hacking_skill;
}, },
getHackingMultipliers : function() { getHackingMultipliers : function() {
@ -956,10 +1057,14 @@ function NetscriptFunctions(workerScript) {
} }
if (server.hostname == "home") { if (server.hostname == "home") {
//Return player's money //Return player's money
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {
workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + formatNumber(Player.money.toNumber(), 2)); workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + formatNumber(Player.money.toNumber(), 2));
}
return Player.money.toNumber(); return Player.money.toNumber();
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {
workerScript.scriptRef.log("getServerMoneyAvailable() returned " + formatNumber(server.moneyAvailable, 2) + " for " + server.hostname); workerScript.scriptRef.log("getServerMoneyAvailable() returned " + formatNumber(server.moneyAvailable, 2) + " for " + server.hostname);
}
return server.moneyAvailable; return server.moneyAvailable;
}, },
getServerSecurityLevel : function(ip){ getServerSecurityLevel : function(ip){
@ -976,7 +1081,9 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); workerScript.scriptRef.log("getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
throw makeRuntimeRejectMsg(workerScript, "getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); throw makeRuntimeRejectMsg(workerScript, "getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerSecurityLevel == null) {
workerScript.scriptRef.log("getServerSecurityLevel() returned " + formatNumber(server.hackDifficulty, 3) + " for " + server.hostname); workerScript.scriptRef.log("getServerSecurityLevel() returned " + formatNumber(server.hackDifficulty, 3) + " for " + server.hostname);
}
return server.hackDifficulty; return server.hackDifficulty;
}, },
getServerBaseSecurityLevel : function(ip){ getServerBaseSecurityLevel : function(ip){
@ -993,7 +1100,9 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); workerScript.scriptRef.log("getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
throw makeRuntimeRejectMsg(workerScript, "getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); throw makeRuntimeRejectMsg(workerScript, "getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerBaseSecurityLevel == null) {
workerScript.scriptRef.log("getServerBaseSecurityLevel() returned " + formatNumber(server.baseDifficulty, 3) + " for " + server.hostname); workerScript.scriptRef.log("getServerBaseSecurityLevel() returned " + formatNumber(server.baseDifficulty, 3) + " for " + server.hostname);
}
return server.baseDifficulty; return server.baseDifficulty;
}, },
getServerMinSecurityLevel : function(ip) { getServerMinSecurityLevel : function(ip) {
@ -1010,7 +1119,9 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); workerScript.scriptRef.log("getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
throw makeRuntimeRejectMsg(workerScript, "getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); throw makeRuntimeRejectMsg(workerScript, "getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMinSecurityLevel == null) {
workerScript.scriptRef.log("getServerMinSecurityLevel() returned " + formatNumber(server.minDifficulty, 3) + " for " + server.hostname); workerScript.scriptRef.log("getServerMinSecurityLevel() returned " + formatNumber(server.minDifficulty, 3) + " for " + server.hostname);
}
return server.minDifficulty; return server.minDifficulty;
}, },
getServerRequiredHackingLevel : function(ip) { getServerRequiredHackingLevel : function(ip) {
@ -1027,7 +1138,9 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip); workerScript.scriptRef.log("getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip);
throw makeRuntimeRejectMsg(workerScript, "getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip); throw makeRuntimeRejectMsg(workerScript, "getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip);
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerRequiredHackingLevel == null) {
workerScript.scriptRef.log("getServerRequiredHackingLevel returned " + formatNumber(server.requiredHackingSkill, 0) + " for " + server.hostname); workerScript.scriptRef.log("getServerRequiredHackingLevel returned " + formatNumber(server.requiredHackingSkill, 0) + " for " + server.hostname);
}
return server.requiredHackingSkill; return server.requiredHackingSkill;
}, },
getServerMaxMoney : function(ip){ getServerMaxMoney : function(ip){
@ -1044,7 +1157,9 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip); workerScript.scriptRef.log("getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip);
throw makeRuntimeRejectMsg(workerScript, "getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip); throw makeRuntimeRejectMsg(workerScript, "getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip);
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMaxMoney == null) {
workerScript.scriptRef.log("getServerMaxMoney() returned " + formatNumber(server.moneyMax, 0) + " for " + server.hostname); workerScript.scriptRef.log("getServerMaxMoney() returned " + formatNumber(server.moneyMax, 0) + " for " + server.hostname);
}
return server.moneyMax; return server.moneyMax;
}, },
getServerGrowth : function(ip) { getServerGrowth : function(ip) {
@ -1061,7 +1176,9 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("getServerGrowth() failed. Invalid IP or hostname passed in: " + ip); workerScript.scriptRef.log("getServerGrowth() failed. Invalid IP or hostname passed in: " + ip);
throw makeRuntimeRejectMsg(workerScript, "getServerGrowth() failed. Invalid IP or hostname passed in: " + ip); throw makeRuntimeRejectMsg(workerScript, "getServerGrowth() failed. Invalid IP or hostname passed in: " + ip);
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerGrowth == null) {
workerScript.scriptRef.log("getServerGrowth() returned " + formatNumber(server.serverGrowth, 0) + " for " + server.hostname); workerScript.scriptRef.log("getServerGrowth() returned " + formatNumber(server.serverGrowth, 0) + " for " + server.hostname);
}
return server.serverGrowth; return server.serverGrowth;
}, },
getServerNumPortsRequired : function(ip) { getServerNumPortsRequired : function(ip) {
@ -1078,7 +1195,9 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip); workerScript.scriptRef.log("getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip);
throw makeRuntimeRejectMsg(workerScript, "getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip); throw makeRuntimeRejectMsg(workerScript, "getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip);
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerNumPortsRequired == null) {
workerScript.scriptRef.log("getServerNumPortsRequired() returned " + formatNumber(server.numOpenPortsRequired, 0) + " for " + server.hostname); workerScript.scriptRef.log("getServerNumPortsRequired() returned " + formatNumber(server.numOpenPortsRequired, 0) + " for " + server.hostname);
}
return server.numOpenPortsRequired; return server.numOpenPortsRequired;
}, },
getServerRam : function(ip) { getServerRam : function(ip) {
@ -1095,7 +1214,9 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("getServerRam() failed. Invalid IP or hostname passed in: " + ip); workerScript.scriptRef.log("getServerRam() failed. Invalid IP or hostname passed in: " + ip);
throw makeRuntimeRejectMsg(workerScript, "getServerRam() failed. Invalid IP or hostname passed in: " + ip); throw makeRuntimeRejectMsg(workerScript, "getServerRam() failed. Invalid IP or hostname passed in: " + ip);
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerRam == null) {
workerScript.scriptRef.log("getServerRam() returned [" + formatNumber(server.maxRam, 2) + "GB, " + formatNumber(server.ramUsed, 2) + "GB]"); workerScript.scriptRef.log("getServerRam() returned [" + formatNumber(server.maxRam, 2) + "GB, " + formatNumber(server.ramUsed, 2) + "GB]");
}
return [server.maxRam, server.ramUsed]; return [server.maxRam, server.ramUsed];
}, },
serverExists : function(ip) { serverExists : function(ip) {
@ -1177,7 +1298,7 @@ function NetscriptFunctions(workerScript) {
return 0; return 0;
} else { } else {
workerScript.loadedFns.getNextHacknetNodeCost = true; workerScript.loadedFns.getNextHacknetNodeCost = true;
return CONSTANTS.ScriptHacknetNodesRamCost; return CONSTANTS.ScriptPurchaseHacknetRamCost;
} }
} }
return getCostOfNextHacknetNode(); return getCostOfNextHacknetNode();
@ -1269,8 +1390,10 @@ function NetscriptFunctions(workerScript) {
if (Engine.currentPage == Engine.Page.StockMarket) { if (Engine.currentPage == Engine.Page.StockMarket) {
updateStockPlayerPosition(stock); updateStockPlayerPosition(stock);
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.buyStock == null) {
workerScript.scriptRef.log("Bought " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" + workerScript.scriptRef.log("Bought " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
formatNumber(stock.price, 2) + " per share"); formatNumber(stock.price, 2) + " per share");
}
return stock.price; return stock.price;
}, },
sellStock : function(symbol, shares) { sellStock : function(symbol, shares) {
@ -1312,9 +1435,11 @@ function NetscriptFunctions(workerScript) {
if (Engine.currentPage == Engine.Page.StockMarket) { if (Engine.currentPage == Engine.Page.StockMarket) {
updateStockPlayerPosition(stock); updateStockPlayerPosition(stock);
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellStock == null) {
workerScript.scriptRef.log("Sold " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" + workerScript.scriptRef.log("Sold " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
formatNumber(stock.price, 2) + " per share. Gained " + formatNumber(stock.price, 2) + " per share. Gained " +
"$" + formatNumber(gains, 2)); "$" + formatNumber(gains, 2));
}
return stock.price; return stock.price;
}, },
shortStock(symbol, shares) { shortStock(symbol, shares) {
@ -1507,7 +1632,9 @@ function NetscriptFunctions(workerScript) {
homeComputer.serversOnNetwork.push(newServ.ip); homeComputer.serversOnNetwork.push(newServ.ip);
newServ.serversOnNetwork.push(homeComputer.ip); newServ.serversOnNetwork.push(homeComputer.ip);
Player.loseMoney(cost); Player.loseMoney(cost);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseServer == null) {
workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + formatNumber(cost, 2)); workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + formatNumber(cost, 2));
}
return newServ.hostname; return newServ.hostname;
}, },
deleteServer : function(hostname) { deleteServer : function(hostname) {
@ -1572,7 +1699,9 @@ function NetscriptFunctions(workerScript) {
for (var i = 0; i < homeComputer.serversOnNetwork.length; ++i) { for (var i = 0; i < homeComputer.serversOnNetwork.length; ++i) {
if (ip == homeComputer.serversOnNetwork[i]) { if (ip == homeComputer.serversOnNetwork[i]) {
homeComputer.serversOnNetwork.splice(i, 1); homeComputer.serversOnNetwork.splice(i, 1);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.deleteServer == null) {
workerScript.scriptRef.log("Deleted server " + hostnameStr); workerScript.scriptRef.log("Deleted server " + hostnameStr);
}
return true; return true;
} }
} }
@ -1604,10 +1733,6 @@ function NetscriptFunctions(workerScript) {
}); });
return res; return res;
}, },
round : function(n) {
if (isNaN(n)) {return 0;}
return Math.round(n);
},
write : function(port, data="", mode="a") { write : function(port, data="", mode="a") {
if (workerScript.checkingRam) { if (workerScript.checkingRam) {
if (workerScript.loadedFns.write) { if (workerScript.loadedFns.write) {
@ -1673,7 +1798,7 @@ function NetscriptFunctions(workerScript) {
if (port == null) { if (port == null) {
throw makeRuntimeRejectMsg(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer"); throw makeRuntimeRejectMsg(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
} }
if (port.length == 0) { if (port.length === 0) {
return "NULL PORT DATA"; return "NULL PORT DATA";
} else { } else {
return port.shift(); return port.shift();
@ -1694,6 +1819,30 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, "Invalid argument passed in for read(): " + port); throw makeRuntimeRejectMsg(workerScript, "Invalid argument passed in for read(): " + port);
} }
}, },
peek : function(port) {
if (workerScript.checkingRam) {
if (workerScript.loadedFns.peek) {
return 0;
} else {
workerScript.loadedFns.peek = true;
return CONSTANTS.ScriptReadWriteRamCost;
}
}
if (isNaN(port) || port < 1 || port > 10) {
throw makeRuntimeRejectMsg(workerScript, "ERR: peek() called with invalid argument. Must be a port number between 1 and 10");
}
var portName = "Port" + String(port);
var port = NetscriptPorts[portName];
if (port == null) {
throw makeRuntimeRejectMsg(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
}
if (port.length === 0) {
return "NULL PORT DATA";
} else {
var foo = port.slice();
return foo[0];
}
},
clear : function(port) { clear : function(port) {
if (workerScript.checkingRam) { if (workerScript.checkingRam) {
if (workerScript.loadedFns.clear) { if (workerScript.loadedFns.clear) {
@ -2020,8 +2169,10 @@ function NetscriptFunctions(workerScript) {
} }
if (Player.isWorking) { if (Player.isWorking) {
var txt = Player.singularityStopWork(); var txt = Player.singularityStopWork();
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.universityCourse == null) {
workerScript.scriptRef.log(txt); workerScript.scriptRef.log(txt);
} }
}
var costMult, expMult; var costMult, expMult;
switch(universityName.toLowerCase()) { switch(universityName.toLowerCase()) {
@ -2082,7 +2233,9 @@ function NetscriptFunctions(workerScript) {
return false; return false;
} }
Player.startClass(costMult, expMult, task); Player.startClass(costMult, expMult, task);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.universityCourse == null) {
workerScript.scriptRef.log("Started " + task + " at " + universityName); workerScript.scriptRef.log("Started " + task + " at " + universityName);
}
return true; return true;
}, },
@ -2109,8 +2262,10 @@ function NetscriptFunctions(workerScript) {
} }
if (Player.isWorking) { if (Player.isWorking) {
var txt = Player.singularityStopWork(); var txt = Player.singularityStopWork();
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.gymWorkout == null) {
workerScript.scriptRef.log(txt); workerScript.scriptRef.log(txt);
} }
}
var costMult, expMult; var costMult, expMult;
switch(gymName.toLowerCase()) { switch(gymName.toLowerCase()) {
case Locations.AevumCrushFitnessGym.toLowerCase(): case Locations.AevumCrushFitnessGym.toLowerCase():
@ -2184,7 +2339,9 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("Invalid stat: " + stat + ". gymWorkout() failed"); workerScript.scriptRef.log("Invalid stat: " + stat + ". gymWorkout() failed");
return false; return false;
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.gymWorkout == null) {
workerScript.scriptRef.log("Started training " + stat + " at " + gymName); workerScript.scriptRef.log("Started training " + stat + " at " + gymName);
}
return true; return true;
}, },
@ -2216,7 +2373,9 @@ function NetscriptFunctions(workerScript) {
Player.loseMoney(200000); Player.loseMoney(200000);
Player.city = cityname; Player.city = cityname;
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain); Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.travelToCity == null) {
workerScript.scriptRef.log("Traveled to " + cityname); workerScript.scriptRef.log("Traveled to " + cityname);
}
return true; return true;
default: default:
workerScript.scriptRef.log("ERROR: Invalid city name passed into travelToCity()."); workerScript.scriptRef.log("ERROR: Invalid city name passed into travelToCity().");
@ -2262,7 +2421,9 @@ function NetscriptFunctions(workerScript) {
Player.getHomeComputer().serversOnNetwork.push(darkweb.ip); Player.getHomeComputer().serversOnNetwork.push(darkweb.ip);
darkweb.serversOnNetwork.push(Player.getHomeComputer().ip); darkweb.serversOnNetwork.push(Player.getHomeComputer().ip);
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain); Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseTor == null) {
workerScript.scriptRef.log("You have purchased a Tor router!"); workerScript.scriptRef.log("You have purchased a Tor router!");
}
return true; return true;
}, },
purchaseProgram(programName) { purchaseProgram(programName) {
@ -2294,8 +2455,9 @@ function NetscriptFunctions(workerScript) {
if (price > 0 && Player.money.gt(price)) { if (price > 0 && Player.money.gt(price)) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.BruteSSHProgram); Player.getHomeComputer().programs.push(Programs.BruteSSHProgram);
workerScript.scriptRef.log("You have purchased the BruteSSH.exe program. The new program " + if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
"can be found on your home computer."); workerScript.scriptRef.log("You have purchased the BruteSSH.exe program. The new program can be found on your home computer.");
}
} else { } else {
workerScript.scriptRef.log("Not enough money to purchase " + programName); workerScript.scriptRef.log("Not enough money to purchase " + programName);
return false; return false;
@ -2306,8 +2468,9 @@ function NetscriptFunctions(workerScript) {
if (price > 0 && Player.money.gt(price)) { if (price > 0 && Player.money.gt(price)) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.FTPCrackProgram); Player.getHomeComputer().programs.push(Programs.FTPCrackProgram);
workerScript.scriptRef.log("You have purchased the FTPCrack.exe program. The new program " + if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
"can be found on your home computer."); workerScript.scriptRef.log("You have purchased the FTPCrack.exe program. The new program can be found on your home computer.");
}
} else { } else {
workerScript.scriptRef.log("Not enough money to purchase " + programName); workerScript.scriptRef.log("Not enough money to purchase " + programName);
return false; return false;
@ -2318,8 +2481,9 @@ function NetscriptFunctions(workerScript) {
if (price > 0 && Player.money.gt(price)) { if (price > 0 && Player.money.gt(price)) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.RelaySMTPProgram); Player.getHomeComputer().programs.push(Programs.RelaySMTPProgram);
workerScript.scriptRef.log("You have purchased the relaySMTP.exe program. The new program " + if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
"can be found on your home computer."); workerScript.scriptRef.log("You have purchased the relaySMTP.exe program. The new program can be found on your home computer.");
}
} else { } else {
workerScript.scriptRef.log("Not enough money to purchase " + programName); workerScript.scriptRef.log("Not enough money to purchase " + programName);
return false; return false;
@ -2330,8 +2494,9 @@ function NetscriptFunctions(workerScript) {
if (price > 0 && Player.money.gt(price)) { if (price > 0 && Player.money.gt(price)) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.HTTPWormProgram); Player.getHomeComputer().programs.push(Programs.HTTPWormProgram);
workerScript.scriptRef.log("You have purchased the HTTPWorm.exe program. The new program " + if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
"can be found on your home computer."); workerScript.scriptRef.log("You have purchased the HTTPWorm.exe program. The new program can be found on your home computer.");
}
} else { } else {
workerScript.scriptRef.log("Not enough money to purchase " + programName); workerScript.scriptRef.log("Not enough money to purchase " + programName);
return false; return false;
@ -2342,8 +2507,9 @@ function NetscriptFunctions(workerScript) {
if (price > 0 && Player.money.gt(price)) { if (price > 0 && Player.money.gt(price)) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.SQLInjectProgram); Player.getHomeComputer().programs.push(Programs.SQLInjectProgram);
workerScript.scriptRef.log("You have purchased the SQLInject.exe program. The new program " + if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
"can be found on your home computer."); workerScript.scriptRef.log("You have purchased the SQLInject.exe program. The new program can be found on your home computer.");
}
} else { } else {
workerScript.scriptRef.log("Not enough money to purchase " + programName); workerScript.scriptRef.log("Not enough money to purchase " + programName);
return false; return false;
@ -2354,8 +2520,9 @@ function NetscriptFunctions(workerScript) {
if (price > 0 && Player.money.gt(price)) { if (price > 0 && Player.money.gt(price)) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.DeepscanV1); Player.getHomeComputer().programs.push(Programs.DeepscanV1);
workerScript.scriptRef.log("You have purchased the DeepscanV1.exe program. The new program " + if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
"can be found on your home computer."); workerScript.scriptRef.log("You have purchased the DeepscanV1.exe program. The new program can be found on your home computer.");
}
} else { } else {
workerScript.scriptRef.log("Not enough money to purchase " + programName); workerScript.scriptRef.log("Not enough money to purchase " + programName);
return false; return false;
@ -2366,8 +2533,9 @@ function NetscriptFunctions(workerScript) {
if (price > 0 && Player.money.gt(price)) { if (price > 0 && Player.money.gt(price)) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.DeepscanV2); Player.getHomeComputer().programs.push(Programs.DeepscanV2);
workerScript.scriptRef.log("You have purchased the DeepscanV2.exe program. The new program " + if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
"can be found on your home computer."); workerScript.scriptRef.log("You have purchased the DeepscanV2.exe program. The new program can be found on your home computer.");
}
} else { } else {
workerScript.scriptRef.log("Not enough money to purchase " + programName); workerScript.scriptRef.log("Not enough money to purchase " + programName);
return false; return false;
@ -2439,7 +2607,9 @@ function NetscriptFunctions(workerScript) {
} }
if (Player.isWorking) { if (Player.isWorking) {
var txt = Player.singularityStopWork(); var txt = Player.singularityStopWork();
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.stopAction == null) {
workerScript.scriptRef.log(txt); workerScript.scriptRef.log(txt);
}
return true; return true;
} }
return false; return false;
@ -2483,7 +2653,9 @@ function NetscriptFunctions(workerScript) {
Player.loseMoney(cost); Player.loseMoney(cost);
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain); Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.upgradeHomeRam == null) {
workerScript.scriptRef.log("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM."); workerScript.scriptRef.log("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM.");
}
return true; return true;
}, },
getUpgradeHomeRamCost() { getUpgradeHomeRamCost() {
@ -2544,15 +2716,19 @@ function NetscriptFunctions(workerScript) {
if (Player.isWorking) { if (Player.isWorking) {
var txt = Player.singularityStopWork(); var txt = Player.singularityStopWork();
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForCompany == null) {
workerScript.scriptRef.log(txt); workerScript.scriptRef.log(txt);
} }
}
if (Player.companyPosition.isPartTimeJob()) { if (Player.companyPosition.isPartTimeJob()) {
Player.startWorkPartTime(); Player.startWorkPartTime();
} else { } else {
Player.startWork(); Player.startWork();
} }
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForCompany == null) {
workerScript.scriptRef.log("Began working at " + Player.companyName + " as a " + Player.companyPosition.positionName); workerScript.scriptRef.log("Began working at " + Player.companyName + " as a " + Player.companyPosition.positionName);
}
return true; return true;
}, },
applyToCompany(companyName, field) { applyToCompany(companyName, field) {
@ -2630,10 +2806,14 @@ function NetscriptFunctions(workerScript) {
return false; return false;
} }
if (res) { if (res) {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.applyToCompany == null) {
workerScript.scriptRef.log("You were offered a new job at " + companyName + " as a " + Player.companyPosition.positionName); workerScript.scriptRef.log("You were offered a new job at " + companyName + " as a " + Player.companyPosition.positionName);
}
} else { } else {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.applyToCompany == null) {
workerScript.scriptRef.log("You failed to get a new job/promotion at " + companyName + " in the " + field + " field."); workerScript.scriptRef.log("You failed to get a new job/promotion at " + companyName + " in the " + field + " field.");
} }
}
return res; return res;
}, },
getCompanyRep(companyName) { getCompanyRep(companyName) {
@ -2719,7 +2899,9 @@ function NetscriptFunctions(workerScript) {
var fac = Factions[name]; var fac = Factions[name];
joinFaction(fac); joinFaction(fac);
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain); Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.joinFaction == null) {
workerScript.scriptRef.log("Joined the " + name + " faction."); workerScript.scriptRef.log("Joined the " + name + " faction.");
}
return true; return true;
}, },
workForFaction(name, type) { workForFaction(name, type) {
@ -2757,8 +2939,10 @@ function NetscriptFunctions(workerScript) {
if (Player.isWorking) { if (Player.isWorking) {
var txt = Player.singularityStopWork(); var txt = Player.singularityStopWork();
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForFaction == null) {
workerScript.scriptRef.log(txt); workerScript.scriptRef.log(txt);
} }
}
var fac = Factions[name]; var fac = Factions[name];
//Arrays listing factions that allow each time of work //Arrays listing factions that allow each time of work
@ -2866,8 +3050,10 @@ function NetscriptFunctions(workerScript) {
} }
if (Player.isWorking) { if (Player.isWorking) {
var txt = Player.singularityStopWork(); var txt = Player.singularityStopWork();
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.createProgram == null) {
workerScript.scriptRef.log(txt); workerScript.scriptRef.log(txt);
} }
}
switch(name.toLowerCase()) { switch(name.toLowerCase()) {
case Programs.NukeProgram.toLowerCase(): case Programs.NukeProgram.toLowerCase():
@ -2966,8 +3152,10 @@ function NetscriptFunctions(workerScript) {
} }
if (Player.isWorking) { if (Player.isWorking) {
var txt = Player.singularityStopWork(); var txt = Player.singularityStopWork();
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null) {
workerScript.scriptRef.log(txt); workerScript.scriptRef.log(txt);
} }
}
//Set Location to slums //Set Location to slums
switch(Player.city) { switch(Player.city) {

@ -19,16 +19,17 @@ function WorkerScript(runningScriptObj) {
this.serverIp = null; this.serverIp = null;
this.code = runningScriptObj.scriptRef.code; this.code = runningScriptObj.scriptRef.code;
this.env = new Environment(this); this.env = new Environment(this);
this.env.set("args", runningScriptObj.args); this.env.set("args", runningScriptObj.args.slice());
this.output = ""; this.output = "";
this.ramUsage = 0; this.ramUsage = 0;
this.scriptRef = runningScriptObj; this.scriptRef = runningScriptObj;
this.errorMessage = ""; this.errorMessage = "";
this.args = runningScriptObj.args; this.args = runningScriptObj.args.slice();
this.delay = null; this.delay = null;
this.fnWorker = null; //Workerscript for a function call this.fnWorker = null; //Workerscript for a function call
this.checkingRam = false; this.checkingRam = false;
this.loadedFns = {}; //Stores names of fns that are "loaded" by this script, thus using RAM this.loadedFns = {}; //Stores names of fns that are "loaded" by this script, thus using RAM
this.disableLogs = {}; //Stores names of fns that should have logs disabled
} }
//Returns the server on which the workerScript is running //Returns the server on which the workerScript is running

@ -1069,7 +1069,8 @@ PlayerObject.prototype.workForFaction = function(numCycles) {
} }
var txt = document.getElementById("work-in-progress-text"); var txt = document.getElementById("work-in-progress-text");
txt.innerHTML = "You are currently " + this.currentWorkFactionDescription + " for your faction " + faction.name + "." + txt.innerHTML = "You are currently " + this.currentWorkFactionDescription + " for your faction " + faction.name +
" (Current Faction Reputation: " + formatNumber(faction.playerReputation, 0) + "). " +
"You have been doing this for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" + "You have been doing this for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" +
"You have earned: <br><br>" + "You have earned: <br><br>" +
"$" + formatNumber(this.workMoneyGained, 2) + " (" + formatNumber(this.workMoneyGainRate * cyclesPerSec, 2) + " / sec) <br><br>" + "$" + formatNumber(this.workMoneyGained, 2) + " (" + formatNumber(this.workMoneyGainRate * cyclesPerSec, 2) + " / sec) <br><br>" +
@ -1949,21 +1950,17 @@ PlayerObject.prototype.reapplyAllAugmentations = function(resetMultipliers=true)
for (let i = 0; i < this.augmentations.length; ++i) { for (let i = 0; i < this.augmentations.length; ++i) {
//Compatibility with new version //Compatibility with new version
if (typeof this.augmentations[i] === 'string' || this.augmentations[i] instanceof String) { if (this.augmentations[i].name === "HacknetNode NIC Architecture Neural-Upload") {
var newOwnedAug = new PlayerOwnedAugmentation(this.augmentations[i]); this.augmentations[i].name = "Hacknet Node NIC Architecture Neural-Upload";
if (this.augmentations[i] == AugmentationNames.NeuroFluxGovernor) {
newOwnedAug.level = Augmentations[AugmentationNames.NeuroFluxGovernor].level;
}
this.augmentations[i] = newOwnedAug;
} }
var augName = this.augmentations[i].name; var augName = this.augmentations[i].name;
var aug = Augmentations[augName]; var aug = Augmentations[augName];
aug.owned = true;
if (aug == null) { if (aug == null) {
console.log("WARNING: Invalid augmentation name"); console.log("WARNING: Invalid augmentation name");
continue; continue;
} }
aug.owned = true;
if (aug.name == AugmentationNames.NeuroFluxGovernor) { if (aug.name == AugmentationNames.NeuroFluxGovernor) {
for (let j = 0; j < aug.level; ++j) { for (let j = 0; j < aug.level; ++j) {
applyAugmentation(this.augmentations[i], true); applyAugmentation(this.augmentations[i], true);

@ -25,6 +25,7 @@ import {initStockMarket, initSymbolToStockMap,
setStockMarketContentCreated} from "./StockMarket.js"; setStockMarketContentCreated} from "./StockMarket.js";
import {Terminal, postNetburnerText} from "./Terminal.js"; import {Terminal, postNetburnerText} from "./Terminal.js";
import Decimal from '../utils/decimal.js'; import Decimal from '../utils/decimal.js';
import {dialogBoxCreate} from "../utils/DialogBox.js";
//Prestige by purchasing augmentation //Prestige by purchasing augmentation
function prestigeAugmentation() { function prestigeAugmentation() {
@ -148,11 +149,8 @@ function prestigeAugmentation() {
function prestigeSourceFile() { function prestigeSourceFile() {
initBitNodeMultipliers(); initBitNodeMultipliers();
//Crime statistics
Player.prestigeSourceFile(); Player.prestigeSourceFile();
prestigeWorkerScripts(); //Delete all Worker Scripts objects
//Delete all Worker Scripts objects
prestigeWorkerScripts();
var homeComp = Player.getHomeComputer(); var homeComp = Player.getHomeComputer();
@ -234,7 +232,7 @@ function prestigeSourceFile() {
//Reinitialize Bit Node flags //Reinitialize Bit Node flags
initSingularitySFFlags(); initSingularitySFFlags();
//Reset Stock market //Reset Stock market, gang, and corporation
if (Player.hasWseAccount) { if (Player.hasWseAccount) {
initStockMarket(); initStockMarket();
initSymbolToStockMap(); initSymbolToStockMap();
@ -245,11 +243,17 @@ function prestigeSourceFile() {
stockMarketList.removeChild(stockMarketList.firstChild); stockMarketList.removeChild(stockMarketList.firstChild);
} }
Player.gang = null;
Player.corporation = null;
//BitNode 3, get Handbook .lit file
homeComp.messages.push("corporation-management-handbook.lit");
dialogBoxCreate("You received a copy of the Corporation Management Handbook on your home computer. " +
"Read it if you need help getting started with Corporations!");
//Gain int exp //Gain int exp
Player.gainIntelligenceExp(5); Player.gainIntelligenceExp(5);
//Reset gang
Player.gang = null;
} }
export {prestigeAugmentation, prestigeSourceFile}; export {prestigeAugmentation, prestigeSourceFile};

@ -76,7 +76,7 @@ function scriptEditorInit() {
var documentationButton = createElement("a", { var documentationButton = createElement("a", {
display:"inline-block", class:"a-link-button", innerText:"Netscript Documentation", display:"inline-block", class:"a-link-button", innerText:"Netscript Documentation",
href:"https://bitburner.wikia.com/wiki/Netscript", href:"https://bitburner.readthedocs.io/en/latest/index.html",
target:"_blank" target:"_blank"
}); });

@ -689,7 +689,7 @@ function processSingleServerGrowth(server, numCycles) {
} }
function prestigeHomeComputer(homeComp) { function prestigeHomeComputer(homeComp) {
homeComp.programs.length = 0; homeComp.programs.length = 0; //Remove programs
homeComp.runningScripts = []; homeComp.runningScripts = [];
homeComp.serversOnNetwork = []; homeComp.serversOnNetwork = [];
homeComp.isConnectedTo = true; homeComp.isConnectedTo = true;
@ -701,7 +701,7 @@ function prestigeHomeComputer(homeComp) {
script.updateRamUsage(); script.updateRamUsage();
}); });
homeComp.messages.length = 0; homeComp.messages.length = 0; //Remove .lit and .msg files
homeComp.messages.push("hackers-starting-handbook.lit"); homeComp.messages.push("hackers-starting-handbook.lit");
} }

@ -506,9 +506,11 @@ function shortStock(stock, shares, workerScript=null) {
stock.playerAvgShortPx = newTotal / stock.playerShortShares; stock.playerAvgShortPx = newTotal / stock.playerShortShares;
updateStockPlayerPosition(stock); updateStockPlayerPosition(stock);
if (tixApi) { if (tixApi) {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.shortStock == null) {
workerScript.scriptRef.log("Bought a short position of " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at " + workerScript.scriptRef.log("Bought a short position of " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at " +
numeral(stock.price).format('($0.000a)') + " per share. Paid " + numeral(stock.price).format('($0.000a)') + " per share. Paid " +
numeral(CONSTANTS.StockMarketCommission).format('($0.000a)') + " in commission fees."); numeral(CONSTANTS.StockMarketCommission).format('($0.000a)') + " in commission fees.");
}
} else { } else {
dialogBoxCreate("Bought a short position of " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" + dialogBoxCreate("Bought a short position of " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
formatNumber(stock.price, 2) + " per share. You also paid $" + formatNumber(stock.price, 2) + " per share. You also paid $" +
@ -548,9 +550,11 @@ function sellShort(stock, shares, workerScript=null) {
} }
updateStockPlayerPosition(stock); updateStockPlayerPosition(stock);
if (tixApi) { if (tixApi) {
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellShort == null) {
workerScript.scriptRef.log("Sold your short position of " + shares + " shares of " + stock.symbol + " at " + workerScript.scriptRef.log("Sold your short position of " + shares + " shares of " + stock.symbol + " at " +
numeral(stock.price).format('($0.000a)') + " per share. After commissions, you gained " + numeral(stock.price).format('($0.000a)') + " per share. After commissions, you gained " +
"a total of " + numeral(origCost + profit).format('($0.000a)')); "a total of " + numeral(origCost + profit).format('($0.000a)'));
}
} else { } else {
dialogBoxCreate("Sold your short position of " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" + dialogBoxCreate("Sold your short position of " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
formatNumber(stock.price, 2) + " per share. After commissions, you gained " + formatNumber(stock.price, 2) + " per share. After commissions, you gained " +

@ -328,6 +328,9 @@ function determineAllPossibilitiesForTabCompletion(input, index=0) {
allPos.push(currServ.messages[i]); allPos.push(currServ.messages[i]);
} }
} }
for (var i = 0; i < currServ.textFiles.length; ++i) {
allPos.push(currServ.textFiles[i].fn);
}
} }
if (input.startsWith("connect ") || input.startsWith("telnet ")) { if (input.startsWith("connect ") || input.startsWith("telnet ")) {
@ -1131,16 +1134,17 @@ let Terminal = {
return; return;
} }
var scriptname = args[0]; var scriptname = args[0];
if (!scriptname.endsWith(".lit") && !scriptname.endsWith(".script")){ if (!scriptname.endsWith(".lit") && !scriptname.endsWith(".script") &&
post("Error: scp only works for .script and .lit files"); !scriptname.endsWith(".txt")){
post("Error: scp only works for .script, .txt, and .lit files");
return; return;
} }
var server = getServer(args[1]); var destServer = getServer(args[1]);
if (server == null) { if (destServer == null) {
post("Invalid destination. " + args[1] + " not found"); post("Invalid destination. " + args[1] + " not found");
return; return;
} }
var ip = server.ip; var ip = destServer.ip;
var currServ = Player.getCurrentServer(); var currServ = Player.getCurrentServer();
//Scp for lit files //Scp for lit files
@ -1149,26 +1153,49 @@ let Terminal = {
for (var i = 0; i < currServ.messages.length; ++i) { for (var i = 0; i < currServ.messages.length; ++i) {
if (!(currServ.messages[i] instanceof Message) && currServ.messages[i] == scriptname) { if (!(currServ.messages[i] instanceof Message) && currServ.messages[i] == scriptname) {
found = true; found = true;
break;
} }
} }
if (!found) { if (!found) {return post("Error: no such file exists!");}
post("Error: no such file exists!");
return;
}
for (var i = 0; i < server.messages.length; ++i) { for (var i = 0; i < destServer.messages.length; ++i) {
if (server.messages[i] === scriptname) { if (destServer.messages[i] === scriptname) {
post(scriptname + " copied over to " + server.hostname); post(scriptname + " copied over to " + destServer.hostname);
return; //Already exists return; //Already exists
} }
} }
server.messages.push(scriptname); destServer.messages.push(scriptname);
post(scriptname + " copied over to " + server.hostname); post(scriptname + " copied over to " + destServer.hostname);
return; return;
} }
//Scp for txt files
if (scriptname.endsWith(".txt")) {
var found = false, txtFile;
for (var i = 0; i < currServ.textFiles.length; ++i) {
if (currServ.textFiles[i].fn === scriptname) {
found = true;
txtFile = currServ.textFiles[i];
break;
}
}
if (!found) {return post("Error: no such file exists!");}
for (var i = 0; i < destServer.textFiles.length; ++i) {
if (destServer.textFiles[i].fn === scriptname) {
//Overwrite
destServer.textFiles[i].text = txtFile.text;
post("WARNING: " + scriptname + " already exists on " + destServer.hostname +
"and will be overwriten");
return post(scriptname + " copied over to " + destServer.hostname);
}
}
var newFile = new TextFile(txtFile.fn, txtFile.text);
destServer.textFiles.push(newFile);
return post(scriptname + " copied over to " + destServer.hostname);
}
//Get the current script //Get the current script
var sourceScript = null; var sourceScript = null;
@ -1184,13 +1211,13 @@ let Terminal = {
} }
//Overwrite script if it exists //Overwrite script if it exists
for (var i = 0; i < server.scripts.length; ++i) { for (var i = 0; i < destServer.scripts.length; ++i) {
if (scriptname == server.scripts[i].filename) { if (scriptname == destServer.scripts[i].filename) {
post("WARNING: " + scriptname + " already exists on " + server.hostname + " and will be overwritten"); post("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and will be overwritten");
var oldScript = server.scripts[i]; var oldScript = destServer.scripts[i];
oldScript.code = sourceScript.code; oldScript.code = sourceScript.code;
oldScript.ramUsage = sourceScript.ramUsage; oldScript.ramUsage = sourceScript.ramUsage;
post(scriptname + " overwriten on " + server.hostname); post(scriptname + " overwriten on " + destServer.hostname);
return; return;
} }
} }
@ -1199,9 +1226,9 @@ let Terminal = {
newScript.filename = scriptname; newScript.filename = scriptname;
newScript.code = sourceScript.code; newScript.code = sourceScript.code;
newScript.ramUsage = sourceScript.ramUsage; newScript.ramUsage = sourceScript.ramUsage;
newScript.server = ip; newScript.destServer = ip;
server.scripts.push(newScript); destServer.scripts.push(newScript);
post(scriptname + " copied over to " + server.hostname); post(scriptname + " copied over to " + destServer.hostname);
break; break;
case "sudov": case "sudov":
if (commandArray.length != 1) { if (commandArray.length != 1) {

@ -21,7 +21,7 @@ TextFile.prototype.read = function() {
} }
TextFile.prototype.show = function() { TextFile.prototype.show = function() {
dialogBoxCreate(this.fn + "<br><br>" + this.text); dialogBoxCreate(this.fn + "<br><br>" + this.text, true);
} }
TextFile.prototype.download = function() { TextFile.prototype.download = function() {

@ -100,6 +100,12 @@ function createElement(type, params) {
class:"tooltiptext", class:"tooltiptext",
innerHTML:params.tooltip innerHTML:params.tooltip
})); }));
} else if (params.tooltipleft) {
el.className += " tooltip";
el.appendChild(createElement("span", {
class:"tooltiptextleft",
innerHTML:params.tooltipleft
}));
} }
if (params.href) {el.href = params.href;} if (params.href) {el.href = params.href;}
if (params.target) {el.target = params.target;} if (params.target) {el.target = params.target;}

@ -139,6 +139,17 @@ function isHTML(str) {
return false; return false;
} }
//Generates a random alphanumeric string with N characters
function generateRandomString(n) {
var str = "",
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < n; i++)
str += chars.charAt(Math.floor(Math.random() * chars.length));
return str;
}
export {getIndicesOf, convertTimeMsToTimeElapsedString, longestCommonStart, export {getIndicesOf, convertTimeMsToTimeElapsedString, longestCommonStart,
isString, isPositiveNumber, containsAllStrings, formatNumber, isString, isPositiveNumber, containsAllStrings, formatNumber,
numOccurrences, numNetscriptOperators, isHTML}; numOccurrences, numNetscriptOperators, isHTML, generateRandomString};

26
webpack.config.js Normal file

@ -0,0 +1,26 @@
var webpack = require('webpack');
module.exports = {
plugins: [
// http://stackoverflow.com/questions/29080148/expose-jquery-to-real-window-object-with-webpack
new webpack.ProvidePlugin({
// Automtically detect jQuery and $ as free var in modules
// and inject the jquery library
// This is required by many jquery plugins
jquery: "jquery",
jQuery: "jquery",
$: "jquery"
}),
],
entry: "./src/engine.js",
output: {
path: __dirname + "/dist/",
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.css$/, loader: "style!css" },
]
}
};