mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-22 14:12:27 +01:00
1798 lines
107 KiB
HTML
1798 lines
107 KiB
HTML
|
|
<!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 Basic Functions — 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="next" title="Netscript Advanced Functions" href="netscriptadvancedfunctions.html" />
|
|
<link rel="prev" title="Netscript Script Arguments" href="netscriptscriptarguments.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="netscriptscriptarguments.html" title="Netscript Script Arguments"
|
|
accesskey="P">previous</a> |
|
|
<a href="netscriptadvancedfunctions.html" title="Netscript Advanced Functions"
|
|
accesskey="N">next</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-basic-functions">
|
|
<h1>Netscript Basic Functions<a class="headerlink" href="#netscript-basic-functions" title="Permalink to this headline">¶</a></h1>
|
|
<p>This page contains the complete documentation for all functions that are available in Netscript.
|
|
This includes information such as function signatures, what they do, and their return values.</p>
|
|
<p>At the end is also a section that describes how to define your own functions in Netscript.</p>
|
|
<div class="section" id="hack">
|
|
<h2>hack<a class="headerlink" href="#hack" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">hack</code><span class="sig-paren">(</span><em>hostname/ip</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>hostname/ip</strong> (<em>string</em>) -- IP or hostname of the target server to hack</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<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>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Function that is used to try and hack servers to steal money and gain hacking experience. The runtime for this command depends
|
|
on your hacking level and the target server's security level. In order to hack a server you must first gain root access
|
|
to that server and also have the required hacking level.</p>
|
|
<p>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.</p>
|
|
<p>A successful hack() on a server will raise that server's security level by 0.002.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">hack</span><span class="p">(</span><span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
<span class="n">hack</span><span class="p">(</span><span class="s2">"10.1.2.3"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="grow">
|
|
<h2>grow<a class="headerlink" href="#grow" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">grow</code><span class="sig-paren">(</span><em>hostname/ip</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>hostname/ip</strong> (<em>string</em>) -- IP or hostname of the target server to grow</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">The number by which the money on the server was multiplied for the growth</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Use your hacking skills to increase the amount of money available on a server. The runtime for this command depends on your hacking
|
|
level and the target server's security level. When grow() completes, the money available on a target server will be increased by a
|
|
certain, fixed percentage. This percentage is determined by the target server's growth rate (which varies between servers) and security level.
|
|
Generally, higher-level servers have higher growth rates. The getServerGrowth() function can be used to obtain a server's growth rate.</p>
|
|
<p>Like hack(), grow() can be called on any server, regardless of where the script is running. The grow() command requires
|
|
root access to the target server, but there is no required hacking level to run the command. It also raises the security level
|
|
of the target server by 0.004.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">grow</span><span class="p">(</span><span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="weaken">
|
|
<h2>weaken<a class="headerlink" href="#weaken" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">weaken</code><span class="sig-paren">(</span><em>hostname/ip</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>hostname.ip</strong> (<em>string</em>) -- IP or hostname of the target server to weaken</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">The amount by which the target server's security level was decreased. This is equivalent to 0.05 multiplied
|
|
by the number of script threads</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Use your hacking skills to attack a server's security, lowering the server's security level. The runtime for this command
|
|
depends on your hacking level and the target server's security level. This function lowers the security level of the target
|
|
server by 0.05.</p>
|
|
<p>Like hack() and grow(), weaken() can be called on any server, regardless of where the script is running. This command requires
|
|
root access to the target server, but there is no required hacking level to run the command.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">weaken</span><span class="p">(</span><span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="sleep">
|
|
<h2>sleep<a class="headerlink" href="#sleep" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<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">
|
|
<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 of milliseconds to sleep</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Suspends the script for n milliseconds.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="print">
|
|
<h2>print<a class="headerlink" href="#print" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">print</code><span class="sig-paren">(</span><em>x</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>x</strong> -- Value to be printed</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Prints a value or a variable to the script's logs.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="tprint">
|
|
<h2>tprint<a class="headerlink" href="#tprint" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">tprint</code><span class="sig-paren">(</span><em>x</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>x</strong> -- Value to be printed</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Prints a value or a variable to the Terminal</p>
|
|
</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 class="section" id="scan">
|
|
<h2>scan<a class="headerlink" href="#scan" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">scan</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="optional">[</span>, <em>hostnames=true</em><span class="optional">]</span><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>hostname/ip</strong> (<em>string</em>) -- IP or hostname of the server to scan</li>
|
|
<li><strong>boolean</strong> -- Optional boolean specifying whether the function should output hostnames (if true) or IP addresses (if false)</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns an array containing the hostnames or IPs of all servers that are one node way from the specified target server. The
|
|
hostnames/IPs in the returned array are strings.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="nuke">
|
|
<h2>nuke<a class="headerlink" href="#nuke" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">nuke</code><span class="sig-paren">(</span><em>hostname/ip</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>hostname/ip</strong> (<em>string</em>) -- IP or hostname of the target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Runs the NUKE.exe program on the target server. NUKE.exe must exist on your home computer.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">nuke</span><span class="p">(</span><span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="brutessh">
|
|
<h2>brutessh<a class="headerlink" href="#brutessh" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">brutessh</code><span class="sig-paren">(</span><em>hostname/ip</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>hostname/ip</strong> (<em>string</em>) -- IP or hostname of the target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Runs the BruteSSH.exe program on the target server. BruteSSH.exe must exist on your home computer.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">brutessh</span><span class="p">(</span><span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="ftpcrack">
|
|
<h2>ftpcrack<a class="headerlink" href="#ftpcrack" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">ftpcrack</code><span class="sig-paren">(</span><em>hostname/ip</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>hostname/ip</strong> (<em>string</em>) -- IP or hostname of the target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Runs the FTPCrack.exe program on the target server. FTPCrack.exe must exist on your home computer.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">ftpcrack</span><span class="p">(</span><span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="relaysmtp">
|
|
<h2>relaysmtp<a class="headerlink" href="#relaysmtp" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">relaysmtp</code><span class="sig-paren">(</span><em>hostname/ip</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>hostname/ip</strong> (<em>string</em>) -- IP or hostname of the target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Runs the relaySMTP.exe program on the target server. relaySMTP.exe must exist on your home computer.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">relaysmtp</span><span class="p">(</span><span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="httpworm">
|
|
<h2>httpworm<a class="headerlink" href="#httpworm" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">httpworm</code><span class="sig-paren">(</span><em>hostname/ip</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>hostname/ip</strong> (<em>string</em>) -- IP or hostname of the target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Runs the HTTPWorm.exe program on the target server. HTTPWorm.exe must exist on your home computer.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">httpworm</span><span class="p">(</span><span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="sqlinject">
|
|
<h2>sqlinject<a class="headerlink" href="#sqlinject" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">sqlinject</code><span class="sig-paren">(</span><em>hostname/ip</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>hostname/ip</strong> (<em>string</em>) -- IP or hostname of the target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Runs the SQLInject.exe program on the target server. SQLInject.exe must exist on your home computer.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">sqlinject</span><span class="p">(</span><span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="run">
|
|
<h2>run<a class="headerlink" href="#run" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">run</code><span class="sig-paren">(</span><em>script</em><span class="optional">[</span>, <em>numThreads=1</em><span class="optional">]</span><span class="optional">[</span>, <em>args...</em><span class="optional">]</span><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>script</strong> (<em>string</em>) -- Filename of script to run</li>
|
|
<li><strong>numThreads</strong> (<em>number</em>) -- Optional thread count for new script. Set to 1 by default. Will be rounded to nearest integer</li>
|
|
<li><strong>args...</strong> -- Additional arguments to pass into the new script that is being run. Note that if any arguments are being
|
|
passed into the new script, then the second argument <em>numThreads</em> must be filled in with a value.</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Run a script as a separate process. This function can only be used to run scripts located on the current server (the server
|
|
running the script that calls this function).</p>
|
|
<p>Returns true if the script is successfully started, and false otherwise. Requires a significant amount of RAM to run this
|
|
command.</p>
|
|
<p>The simplest way to use the <em>run</em> command is to call it with just the script name. The following example will run
|
|
'foo.script' single-threaded with no arguments:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">run</span><span class="p">(</span><span class="s2">"foo.script"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The following example will run 'foo.script' but with 5 threads instead of single-threaded:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">run</span><span class="p">(</span><span class="s2">"foo.script"</span><span class="p">,</span> <span class="mi">5</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>This next example will run 'foo.script' single-threaded, and will pass the string 'foodnstuff' into the script
|
|
as an argument:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">run</span><span class="p">(</span><span class="s2">"foo.script"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">'foodnstuff'</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="exec">
|
|
<h2>exec<a class="headerlink" href="#exec" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">exec</code><span class="sig-paren">(</span><em>script</em>, <em>hostname/ip</em><span class="optional">[</span>, <em>numThreads=1</em><span class="optional">]</span><span class="optional">[</span>, <em>args...</em><span class="optional">]</span><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>script</strong> (<em>string</em>) -- Filename of script to execute</li>
|
|
<li><strong>hostname/ip</strong> (<em>string</em>) -- IP or hostname of the 'target server' on which to execute the script</li>
|
|
<li><strong>numThreads</strong> (<em>number</em>) -- Optional thread count for new script. Set to 1 by default. Will be rounded to nearest integer</li>
|
|
<li><strong>args...</strong> -- Additional arguments to pass into the new script that is being run. Note that if any arguments are being
|
|
passed into the new script, then the third argument <em>numThreads</em> must be filled in with a value.</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Run a script as a separate process on a specified server. This is similar to the <em>run</em> function except
|
|
that it can be used to run a script on any server, instead of just the current server.</p>
|
|
<p>Returns true if the script is successfully started, and false otherwise.</p>
|
|
<p>The simplest way to use the <em>exec</em> command is to call it with just the script name and the target server.
|
|
The following example will try to run <em>generic-hack.script</em> on the <em>foodnstuff</em> server:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">exec</span><span class="p">(</span><span class="s2">"generic-hack.script"</span><span class="p">,</span> <span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The following example will try to run the script <em>generic-hack.script</em> on the <em>joesguns</em> server with 10 threads:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">exec</span><span class="p">(</span><span class="s2">"generic-hack.script"</span><span class="p">,</span> <span class="s2">"joesguns"</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>This last example will try to run the script <em>foo.script</em> on the <em>foodnstuff</em> server with 5 threads. It will also pass
|
|
the number 1 and the string "test" in as arguments to the script:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">exec</span><span class="p">(</span><span class="s2">"foo.script"</span><span class="p">,</span> <span class="s2">"foodnstuff"</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"test"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="spawn">
|
|
<h2>spawn<a class="headerlink" href="#spawn" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">spawn</code><span class="sig-paren">(</span><em>script</em>, <em>numThreads</em><span class="optional">[</span>, <em>args...</em><span class="optional">]</span><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>script</strong> (<em>string</em>) -- Filename of script to execute</li>
|
|
<li><strong>numThreads</strong> (<em>number</em>) -- Number of threads to spawn new script with. Will be rounded to nearest integer</li>
|
|
<li><strong>args...</strong> -- Additional arguments to pass into the new script that is being run.</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Terminates the current script, and then after a delay of about 20 seconds it will execute the newly-specified script.
|
|
The purpose of this function is to execute a new script without being constrained by the RAM usage of the current one.
|
|
This function can only be used to run scripts on the local server.</p>
|
|
<p>Because this function immediately terminates the script, it does not have a return value.</p>
|
|
<p>The following example will execute the script 'foo.script' with 10 threads and the arguments 'foodnstuff' and 90:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">spawn</span><span class="p">(</span><span class="s1">'foo.script'</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s1">'foodnstuff'</span><span class="p">,</span> <span class="mi">90</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="kill">
|
|
<h2>kill<a class="headerlink" href="#kill" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">kill</code><span class="sig-paren">(</span><em>script</em>, <em>hostname/ip</em><span class="optional">[</span>, <em>args...</em><span class="optional">]</span><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>script</strong> (<em>string</em>) -- Filename of the script to kill</li>
|
|
<li><strong>hostname/ip</strong> (<em>string</em>) -- IP or hostname of the server on which to kill the script</li>
|
|
<li><strong>args...</strong> -- Arguments to identify which script to kill</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Kills the script on the target server specified by the script's name and arguments. Remember that scripts
|
|
are uniquely identified by both their name and arguments. For example, if <em>foo.script</em> is run with the argument 1, then this
|
|
is not the same as <em>foo.script</em> run with the argument 2, even though they have the same code.</p>
|
|
<p>If this function successfully kills the specified script, then it will return true. Otherwise, it will return false.</p>
|
|
<p>Examples:</p>
|
|
<p>The following example will try to kill a script named <em>foo.script</em> on the <em>foodnstuff</em> server that was ran with no arguments:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">kill</span><span class="p">(</span><span class="s2">"foo.script"</span><span class="p">,</span> <span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The following will try to kill a script named <em>foo.script</em> on the current server that was ran with no arguments:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">kill</span><span class="p">(</span><span class="s2">"foo.script"</span><span class="p">,</span> <span class="n">getHostname</span><span class="p">());</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The following will try to kill a script named <em>foo.script</em> on the current server that was ran with the arguments 1 and "foodnstuff":</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">kill</span><span class="p">(</span><span class="s2">"foo.script"</span><span class="p">,</span> <span class="n">getHostname</span><span class="p">(),</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="killall">
|
|
<h2>killall<a class="headerlink" href="#killall" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">killall</code><span class="sig-paren">(</span><em>hostname/ip</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>hostname/ip</strong> (<em>string</em>) -- IP or hostname of the server on which to kill all scripts</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<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>
|
|
|
|
</div>
|
|
<div class="section" id="exit">
|
|
<h2>exit<a class="headerlink" href="#exit" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">exit</code><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
|
|
<dd><p>Terminates the current script immediately</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="scp">
|
|
<h2>scp<a class="headerlink" href="#scp" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">scp</code><span class="sig-paren">(</span><em>files</em>, <span class="optional">[</span><em>source</em>, <span class="optional">]</span><em>destination</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>files</strong> (<em>string/array</em>) -- Filename or an array of filenames of script/literature files to copy</li>
|
|
<li><strong>source</strong> (<em>string</em>) -- Hostname or IP of the source server, which is the server from which the file will be copied.
|
|
This argument is optional and if it's omitted the source will be the current server.</li>
|
|
<li><strong>destination</strong> (<em>string</em>) -- Hostname or IP of the destination server, which is the server to which the file will be copied.</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Copies a script or literature (.lit) file(s) to another server. The <em>files</em> argument can be either a string specifying a
|
|
single file to copy, or an array of strings specifying multiple files to copy.</p>
|
|
<p>Returns true if the script/literature file is successfully copied over and false otherwise. If the <em>files</em> argument is an array
|
|
then this function will return true if at least one of the files in the array is successfully copied.</p>
|
|
<p>Examples:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">//</span><span class="n">Copies</span> <span class="n">hack</span><span class="o">-</span><span class="n">template</span><span class="o">.</span><span class="n">script</span> <span class="kn">from</span> <span class="nn">the</span> <span class="n">current</span> <span class="n">server</span> <span class="n">to</span> <span class="n">foodnstuff</span>
|
|
<span class="n">scp</span><span class="p">(</span><span class="s2">"hack-template.script"</span><span class="p">,</span> <span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
|
|
<span class="o">//</span><span class="n">Copies</span> <span class="n">foo</span><span class="o">.</span><span class="n">lit</span> <span class="kn">from</span> <span class="nn">the</span> <span class="n">helios</span> <span class="n">server</span> <span class="n">to</span> <span class="n">the</span> <span class="n">home</span> <span class="n">computer</span>
|
|
<span class="n">scp</span><span class="p">(</span><span class="s2">"foo.lit"</span><span class="p">,</span> <span class="s2">"helios"</span><span class="p">,</span> <span class="s2">"home"</span><span class="p">);</span>
|
|
|
|
<span class="o">//</span><span class="n">Tries</span> <span class="n">to</span> <span class="n">copy</span> <span class="n">three</span> <span class="n">files</span> <span class="kn">from</span> <span class="nn">rothman</span><span class="o">-</span><span class="n">uni</span> <span class="n">to</span> <span class="n">home</span> <span class="n">computer</span>
|
|
<span class="n">files</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"foo1.lit"</span><span class="p">,</span> <span class="s2">"foo2.script"</span><span class="p">,</span> <span class="s2">"foo3.script"</span><span class="p">];</span>
|
|
<span class="n">scp</span><span class="p">(</span><span class="n">files</span><span class="p">,</span> <span class="s2">"rothman-uni"</span><span class="p">,</span> <span class="s2">"home"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="ls">
|
|
<h2>ls<a class="headerlink" href="#ls" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<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">
|
|
<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>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>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns an array with the filenames of all files on the specified server (as strings). The returned array
|
|
is sorted in alphabetic order</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="ps">
|
|
<h2>ps<a class="headerlink" href="#ps" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">ps</code><span class="sig-paren">(</span><em>hostname/ip=current ip</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>ip</strong> (<em>string</em>) -- Hostname or IP address of the target server.
|
|
If not specified, it will be the current server's IP by default</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns an array with general information about all scripts running on the specified
|
|
target server. The information for each server is given in an object with
|
|
the following structure:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="p">{</span>
|
|
<span class="n">filename</span><span class="p">:</span> <span class="n">Script</span> <span class="n">name</span><span class="p">,</span>
|
|
<span class="n">threads</span><span class="p">:</span> <span class="n">Number</span> <span class="n">of</span> <span class="n">threads</span> <span class="n">script</span> <span class="ow">is</span> <span class="n">running</span> <span class="k">with</span><span class="p">,</span>
|
|
<span class="n">args</span><span class="p">:</span> <span class="n">Script</span><span class="s1">'s arguments</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Example usage (using <a class="reference internal" href="netscriptjs.html"><span class="doc">NetscriptJS (Netscript 2.0)</span></a>):</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">export</span> <span class="k">async</span> <span class="n">function</span> <span class="n">main</span><span class="p">(</span><span class="n">ns</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="n">const</span> <span class="n">ps</span> <span class="o">=</span> <span class="n">ns</span><span class="o">.</span><span class="n">ps</span><span class="p">(</span><span class="s2">"home"</span><span class="p">);</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="n">let</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">ps</span><span class="o">.</span><span class="n">length</span><span class="p">;</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="n">ns</span><span class="o">.</span><span class="n">tprint</span><span class="p">(</span><span class="n">ps</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">filename</span> <span class="o">+</span> <span class="s1">' '</span> <span class="o">+</span> <span class="n">ps</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">threads</span><span class="p">);</span>
|
|
<span class="n">ns</span><span class="o">.</span><span class="n">tprint</span><span class="p">(</span><span class="n">ps</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">args</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="hasrootaccess">
|
|
<h2>hasRootAccess<a class="headerlink" href="#hasrootaccess" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="hasRootAccess">
|
|
<code class="descname">hasRootAccess</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#hasRootAccess" 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>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of the target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns a boolean indicating whether or not the player has root access to the specified target server.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="n">hasRootAccess</span><span class="p">(</span><span class="s2">"foodnstuff"</span><span class="p">)</span> <span class="o">==</span> <span class="n">false</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="n">nuke</span><span class="p">(</span><span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="gethostname">
|
|
<h2>getHostname<a class="headerlink" href="#gethostname" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getHostname">
|
|
<code class="descname">getHostname</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getHostname" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns a string with the hostname of the server that the script is running on</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="gethackinglevel">
|
|
<h2>getHackingLevel<a class="headerlink" href="#gethackinglevel" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getHackingLevel">
|
|
<code class="descname">getHackingLevel</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getHackingLevel" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns the player's current hacking level</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="gethackingmultipliers">
|
|
<h2>getHackingMultipliers<a class="headerlink" href="#gethackingmultipliers" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getHackingMultipliers">
|
|
<code class="descname">getHackingMultipliers</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getHackingMultipliers" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns an object containing the Player's hacking related multipliers. These multipliers are
|
|
returned in fractional forms, not percentages (e.g. 1.5 instead of 150%). The object has the following structure:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="p">{</span>
|
|
<span class="n">chance</span><span class="p">:</span> <span class="n">Player</span><span class="s1">'s hacking chance multiplier,</span>
|
|
<span class="n">speed</span><span class="p">:</span> <span class="n">Player</span><span class="s1">'s hacking speed multiplier,</span>
|
|
<span class="n">money</span><span class="p">:</span> <span class="n">Player</span><span class="s1">'s hacking money stolen multiplier,</span>
|
|
<span class="n">growth</span><span class="p">:</span> <span class="n">Player</span><span class="s1">'s hacking growth multiplier</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Example of how this can be used:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">mults</span> <span class="o">=</span> <span class="n">getHackingMultipliers</span><span class="p">();</span>
|
|
<span class="nb">print</span><span class="p">(</span><span class="n">mults</span><span class="o">.</span><span class="n">chance</span><span class="p">);</span>
|
|
<span class="nb">print</span><span class="p">(</span><span class="n">mults</span><span class="o">.</span><span class="n">growth</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="gethacknetmultipliers">
|
|
<h2>getHacknetMultipliers<a class="headerlink" href="#gethacknetmultipliers" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getHacknetMultipliers">
|
|
<code class="descname">getHacknetMultipliers</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getHacknetMultipliers" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns an object containing the Player's hacknet related multipliers. These multipliers are
|
|
returned in fractional forms, not percentages (e.g. 1.5 instead of 150%). The object has the following structure:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="p">{</span>
|
|
<span class="n">production</span><span class="p">:</span> <span class="n">Player</span><span class="s1">'s hacknet production multiplier,</span>
|
|
<span class="n">purchaseCost</span><span class="p">:</span> <span class="n">Player</span><span class="s1">'s hacknet purchase cost multiplier,</span>
|
|
<span class="n">ramCost</span><span class="p">:</span> <span class="n">Player</span><span class="s1">'s hacknet ram cost multiplier,</span>
|
|
<span class="n">coreCost</span><span class="p">:</span> <span class="n">Player</span><span class="s1">'s hacknet core cost multiplier,</span>
|
|
<span class="n">levelCost</span><span class="p">:</span> <span class="n">Player</span><span class="s1">'s hacknet level cost multiplier</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Example of how this can be used:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">mults</span> <span class="o">=</span> <span class="n">getHacknetMultipliers</span><span class="p">();</span>
|
|
<span class="nb">print</span><span class="p">(</span><span class="n">mults</span><span class="o">.</span><span class="n">production</span><span class="p">);</span>
|
|
<span class="nb">print</span><span class="p">(</span><span class="n">mults</span><span class="o">.</span><span class="n">purchaseCost</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getservermoneyavailable">
|
|
<h2>getServerMoneyAvailable<a class="headerlink" href="#getservermoneyavailable" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getServerMoneyAvailable">
|
|
<code class="descname">getServerMoneyAvailable</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#getServerMoneyAvailable" 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>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the amount of money available on a server. <strong>Running this function on the home computer will return
|
|
the player's money.</strong></p>
|
|
<p>Example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">getServerMoneyAvailable</span><span class="p">(</span><span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
<span class="n">getServerMoneyAvailable</span><span class="p">(</span><span class="s2">"home"</span><span class="p">);</span> <span class="o">//</span><span class="n">Returns</span> <span class="n">player</span><span class="s1">'s money</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getservermaxmoney">
|
|
<h2>getServerMaxMoney<a class="headerlink" href="#getservermaxmoney" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getServerMaxMoney">
|
|
<code class="descname">getServerMaxMoney</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#getServerMaxMoney" 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>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the maximum amount of money that can be available on a server</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getservergrowth">
|
|
<h2>getServerGrowth<a class="headerlink" href="#getservergrowth" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getServerGrowth">
|
|
<code class="descname">getServerGrowth</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#getServerGrowth" 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>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the server's instrinsic "growth parameter". This growth parameter is a number
|
|
between 1 and 100 that represents how quickly the server's money grows. This parameter affects the
|
|
percentage by which the server's money is increased when using the <em>grow()</em> function. A higher
|
|
growth parameter will result in a higher percentage increase from <em>grow()</em>.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getserversecuritylevel">
|
|
<h2>getServerSecurityLevel<a class="headerlink" href="#getserversecuritylevel" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getServerSecurityLevel">
|
|
<code class="descname">getServerSecurityLevel</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#getServerSecurityLevel" 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>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the security level of the target server. A server's security level is denoted by a number, typically
|
|
between 1 and 100 (but it can go above 100).</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getserverbasesecuritylevel">
|
|
<h2>getServerBaseSecurityLevel<a class="headerlink" href="#getserverbasesecuritylevel" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getServerBaseSecurityLevel">
|
|
<code class="descname">getServerBaseSecurityLevel</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#getServerBaseSecurityLevel" 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>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the base security level of the target server. This is the security level that the server starts out with.
|
|
This is different than <em>getServerSecurityLevel()</em> because <em>getServerSecurityLevel()</em> returns the current
|
|
security level of a server, which can constantly change due to <em>hack()</em>, <em>grow()</em>, and <em>weaken()</em>, calls on that
|
|
server. The base security level will stay the same until you reset by installing an Augmentation(s).</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getserverminsecuritylevel">
|
|
<h2>getServerMinSecurityLevel<a class="headerlink" href="#getserverminsecuritylevel" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getServerMinSecurityLevel">
|
|
<code class="descname">getServerMinSecurityLevel</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#getServerMinSecurityLevel" 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>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the minimum security level of the target server</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getserverrequiredhackinglevel">
|
|
<h2>getServerRequiredHackingLevel<a class="headerlink" href="#getserverrequiredhackinglevel" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getServerRequiredHackingLevel">
|
|
<code class="descname">getServerRequiredHackingLevel</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#getServerRequiredHackingLevel" 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>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the required hacking level of the target server</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getservernumportsrequired">
|
|
<h2>getServerNumPortsRequired<a class="headerlink" href="#getservernumportsrequired" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getServerNumPortsRequired">
|
|
<code class="descname">getServerNumPortsRequired</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#getServerNumPortsRequired" 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>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the number of open ports required to successfully run NUKE.exe on the specified server.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getserverram">
|
|
<h2>getServerRam<a class="headerlink" href="#getserverram" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getServerRam">
|
|
<code class="descname">getServerRam</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#getServerRam" 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>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns an array with two elements that gives information about a server's memory (RAM). The first
|
|
element in the array is the amount of RAM that the server has total (in GB). The second element in
|
|
the array is the amount of RAM that is currently being used on the server (in GB).</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">res</span> <span class="o">=</span> <span class="n">getServerRam</span><span class="p">(</span><span class="s2">"helios"</span><span class="p">);</span>
|
|
<span class="n">totalRam</span> <span class="o">=</span> <span class="n">res</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
|
|
<span class="n">ramUsed</span> <span class="o">=</span> <span class="n">res</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="serverexists">
|
|
<h2>serverExists<a class="headerlink" href="#serverexists" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="serverExists">
|
|
<code class="descname">serverExists</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#serverExists" 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>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns a boolean denoting whether or not the specified server exists</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="fileexists">
|
|
<h2>fileExists<a class="headerlink" href="#fileexists" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="fileExists">
|
|
<code class="descname">fileExists</code><span class="sig-paren">(</span><em>filename</em><span class="optional">[</span>, <em>hostname/ip</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#fileExists" 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>filename</strong> (<em>string</em>) -- Filename of file to check</li>
|
|
<li><strong>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server. This is optional. If it is not specified then the
|
|
function will use the current server as the target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns a boolean indicating whether the specified file exists on the target server. The filename
|
|
for scripts is case-sensitive, but for other types of files it is not. For example, <em>fileExists("brutessh.exe")</em>
|
|
will work fine, even though the actual program is named "BruteSSH.exe".</p>
|
|
<p>If the <em>hostname/ip</em> argument is omitted, then the function will search through the current server (the server
|
|
running the script that calls this function) for the file.</p>
|
|
<p>Examples:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">fileExists</span><span class="p">(</span><span class="s2">"foo.script"</span><span class="p">,</span> <span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
<span class="n">fileExists</span><span class="p">(</span><span class="s2">"ftpcrack.exe"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The first example above will return true if the script named <em>foo.script</em> exists on the <em>foodnstuff</em> server, and false otherwise.
|
|
The second example above will return true if the current server contains the <em>FTPCrack.exe</em> program, and false otherwise.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="isrunning">
|
|
<h2>isRunning<a class="headerlink" href="#isrunning" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="isRunning">
|
|
<code class="descname">isRunning</code><span class="sig-paren">(</span><em>filename</em>, <em>hostname/ip</em><span class="optional">[</span>, <em>args...</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#isRunning" 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>filename</strong> (<em>string</em>) -- Filename of script to check. This is case-sensitive.</li>
|
|
<li><strong>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
<li><strong>args...</strong> -- Arguments to specify/identify which scripts to search for</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns a boolean indicating whether the specified script is running on the target server. Remember that a script is
|
|
uniquely identified by both its name and its arguments.</p>
|
|
<p><strong>Examples:</strong></p>
|
|
<p>In this first example below, the function call will return true if there is a script named <em>foo.script</em> with no arguments
|
|
running on the <em>foodnstuff</em> server, and false otherwise:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">isRunning</span><span class="p">(</span><span class="s2">"foo.script"</span><span class="p">,</span> <span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>In this second example below, the function call will return true if there is a script named <em>foo.script</em> with no arguments
|
|
running on the current server, and false otherwise:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">isRunning</span><span class="p">(</span><span class="s2">"foo.script"</span><span class="p">,</span> <span class="n">getHostname</span><span class="p">());</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>In this next example below, the function call will return true if there is a script named <em>foo.script</em> running with the arguments
|
|
1, 5, and "test" (in that order) on the <em>joesguns</em> server, and false otherwise:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">isRunning</span><span class="p">(</span><span class="s2">"foo.script"</span><span class="p">,</span> <span class="s2">"joesguns"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="s2">"test"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getnexthacknetnodecost">
|
|
<h2>getNextHacknetNodeCost<a class="headerlink" href="#getnexthacknetnodecost" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getNextHacknetNodeCost">
|
|
<code class="descname">getNextHacknetNodeCost</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getNextHacknetNodeCost" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns the cost of purchasing a new Hacknet Node</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="purchasehacknetnode">
|
|
<h2>purchaseHacknetNode<a class="headerlink" href="#purchasehacknetnode" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="purchaseHacknetNode">
|
|
<code class="descname">purchaseHacknetNode</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#purchaseHacknetNode" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Purchases a new Hacknet Node. Returns a number with the index of the Hacknet Node. This index is equivalent to the number at the
|
|
end of the Hacknet Node's name (e.g The Hacknet Node named 'hacknet-node-4' will have an index of 4). If the player cannot afford
|
|
to purchase a new Hacknet Node then the function will return false.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="purchaseserver">
|
|
<h2>purchaseServer<a class="headerlink" href="#purchaseserver" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="purchaseServer">
|
|
<code class="descname">purchaseServer</code><span class="sig-paren">(</span><em>hostname</em>, <em>ram</em><span class="sig-paren">)</span><a class="headerlink" href="#purchaseServer" 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>hostname</strong> (<em>string</em>) -- Hostname of the purchased server</li>
|
|
<li><strong>ram</strong> (<em>number</em>) -- Amount of RAM of the purchased server. Must be a power of 2 (2, 4, 8, 16, etc.). Maximum value of 1048576 (2^20)</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Purchased a server with the specified hostname and amount of RAM.</p>
|
|
<p>The <em>hostname</em> argument can be any data type, but it will be converted to a string and have whitespace removed. Anything that resolves to an empty string will
|
|
cause the function to fail. If there is already a server with the specified hostname, then the function will automatically append
|
|
a number at the end of the <em>hostname</em> argument value until it finds a unique hostname. For example, if the script calls
|
|
<em>purchaseServer("foo", 4)</em> but a server named "foo" already exists, the it will automatically change the hostname to "foo-0". If there is already
|
|
a server with the hostname "foo-0", then it will change the hostname to "foo-1", and so on.</p>
|
|
<p>Note that there is a maximum limit to the amount of servers you can purchase.</p>
|
|
<p>Returns the hostname of the newly purchased server as a string. If the function fails to purchase a server, then it will return an
|
|
empty string. The function will fail if the arguments passed in are invalid, if the player does not have enough money to purchase
|
|
the specified server, or if the player has exceeded the maximum amount of servers.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">ram</span> <span class="o">=</span> <span class="mi">64</span><span class="p">;</span>
|
|
<span class="n">hn</span> <span class="o">=</span> <span class="s2">"pserv-"</span><span class="p">;</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o"><</span> <span class="mi">5</span><span class="p">;</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="n">purchaseServer</span><span class="p">(</span><span class="n">hn</span> <span class="o">+</span> <span class="n">i</span><span class="p">,</span> <span class="n">ram</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="deleteserver">
|
|
<h2>deleteServer<a class="headerlink" href="#deleteserver" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="deleteServer">
|
|
<code class="descname">deleteServer</code><span class="sig-paren">(</span><em>hostname</em><span class="sig-paren">)</span><a class="headerlink" href="#deleteServer" 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>hostname</strong> (<em>string</em>) -- Hostname of the server to delete</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Deletes one of your purchased servers, which is specified by its hostname.</p>
|
|
<p>The <em>hostname</em> argument can be any data type, but it will be converted to a string. Whitespace is automatically removed from
|
|
the string. This function will not delete a server that still has scripts running on it.</p>
|
|
<p>Returns true if successful, and false otherwise.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getpurchasedservers">
|
|
<h2>getPurchasedServers<a class="headerlink" href="#getpurchasedservers" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getPurchasedServers">
|
|
<code class="descname">getPurchasedServers</code><span class="sig-paren">(</span><span class="optional">[</span><em>hostname=true</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#getPurchasedServers" 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>hostname</strong> (<em>boolean</em>) -- Specifies whether hostnames or IP addresses should be returned. If it's true then hostnames will be returned, and if false
|
|
then IPs will be returned. If this argument is omitted then it is true by default</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns an array with either the hostnames or IPs of all of the servers you have purchased.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="write">
|
|
<h2>write<a class="headerlink" href="#write" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">write</code><span class="sig-paren">(</span><em>port/fn</em>, <em>data=""</em>, <em>mode="a"</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/fn</strong> (<em>string/number</em>) -- Port or text file that will be written to</li>
|
|
<li><strong>data</strong> (<em>string</em>) -- Data to write</li>
|
|
<li><strong>mode</strong> (<em>string</em>) -- Defines the write mode. Only valid when writing to text files.</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>This function can be used to either write data to a port or to a text file (.txt).</p>
|
|
<p>If the first argument is a number between 1 and 10, then it specifies a port and this function will write <em>data</em> to that port. Read
|
|
about how <a class="reference external" href="http://bitburner.wikia.com/wiki/Netscript_Ports">Netscript Ports work here</a>. The third argument, <em>mode</em>, is not used
|
|
when writing to a port.</p>
|
|
<p>If the first argument is a string, then it specifies the name of a text file (.txt) and this function will write <em>data</em> to that text file. If the
|
|
specified text file does not exist, then it will be created. The third argument <em>mode, defines how the data will be written to the text file. If *mode</em>
|
|
is set to "w", then the data is written in "write" mode which means that it will overwrite all existing data on the text file. If <em>mode</em> is set to
|
|
any other value then the data will be written in "append" mode which means that the data will be added at the end of the text file.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="read">
|
|
<h2>read<a class="headerlink" href="#read" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">read</code><span class="sig-paren">(</span><em>port/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 last simple">
|
|
<li><strong>port/fn</strong> (<em>string/number</em>) -- Port or text file to read from</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>This function is used to read data from a port or from a text file (.txt).</p>
|
|
<p>If the argument <em>port/fn</em> is a number between 1 and 10, then it specifies a port and it will read data from that port. Read
|
|
about how <a class="reference external" href="http://bitburner.wikia.com/wiki/Netscript_Ports">Netscript Ports work here</a>. A port is a serialized queue. This function
|
|
will remove the first element from that queue and return it. If the queue is empty, then the string "NULL PORT DATA" will be returned.</p>
|
|
<p>If the argument <em>port/fn</em> 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.</p>
|
|
</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 "NULL PORT DATA" 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 class="section" id="clear">
|
|
<h2>clear<a class="headerlink" href="#clear" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">clear</code><span class="sig-paren">(</span><em>port/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 last simple">
|
|
<li><strong>port/fn</strong> (<em>string/number</em>) -- Port or text file to clear</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>This function is used to clear data in a <a class="reference external" href="http://bitburner.wikia.com/wiki/Netscript_Ports">Netscript Ports</a> or a text file.</p>
|
|
<p>If the <em>port/fn</em> argument is a number between 1 and 10, then it specifies a port and will clear it (deleting all data from the underlying queue).</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>
|
|
|
|
</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 class="section" id="scriptrunning">
|
|
<h2>scriptRunning<a class="headerlink" href="#scriptrunning" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="scriptRunning">
|
|
<code class="descname">scriptRunning</code><span class="sig-paren">(</span><em>scriptname</em>, <em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#scriptRunning" 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>scriptname</strong> (<em>string</em>) -- Filename of script to check. This is case-sensitive.</li>
|
|
<li><strong>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns a boolean indicating whether any instance of the specified script is running on the target server, regardless of
|
|
its arguments.</p>
|
|
<p>This is different than the <em>isRunning()</em> function because it does not try to identify a specific instance of a running script
|
|
by its arguments.</p>
|
|
<p><strong>Examples:</strong></p>
|
|
<p>The example below will return true if there is any script named <em>foo.script</em> running on the <em>foodnstuff</em> server, and false otherwise:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">scriptRunning</span><span class="p">(</span><span class="s2">"foo.script"</span><span class="p">,</span> <span class="s2">"foodnstuff"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The example below will return true if there is any script named "foo.script" running on the current server, and false otherwise:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">scriptRunning</span><span class="p">(</span><span class="s2">"foo.script"</span><span class="p">,</span> <span class="n">getHostname</span><span class="p">());</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="scriptkill">
|
|
<h2>scriptKill<a class="headerlink" href="#scriptkill" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="scriptKill">
|
|
<code class="descname">scriptKill</code><span class="sig-paren">(</span><em>scriptname</em>, <em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#scriptKill" 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>scriptname</strong> (<em>string</em>) -- Filename of script to kill. This is case-sensitive.</li>
|
|
<li><strong>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Kills all scripts with the specified filename on the target server specified by <em>hostname/ip</em>, regardless of arguments. Returns
|
|
true if one or more scripts were successfully killed, and false if none were.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getscriptname">
|
|
<h2>getScriptName<a class="headerlink" href="#getscriptname" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getScriptName">
|
|
<code class="descname">getScriptName</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getScriptName" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns the current script name</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getscriptram">
|
|
<h2>getScriptRam<a class="headerlink" href="#getscriptram" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getScriptRam">
|
|
<code class="descname">getScriptRam</code><span class="sig-paren">(</span><em>scriptname</em><span class="optional">[</span>, <em>hostname/ip</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#getScriptRam" 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>scriptname</strong> (<em>string</em>) -- Filename of script. This is case-sensitive.</li>
|
|
<li><strong>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server the script is located on. This is optional, If it is not specified then the function will se the current server as the target server.</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the amount of RAM required to run the specified script on the target server. Returns
|
|
0 if the script does not exist.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="gethacktime">
|
|
<h2>getHackTime<a class="headerlink" href="#gethacktime" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getHackTime">
|
|
<code class="descname">getHackTime</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#getHackTime" 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>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the amount of time in seconds it takes to execute the <em>hack()</em> Netscript function on the target server.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getgrowtime">
|
|
<h2>getGrowTime<a class="headerlink" href="#getgrowtime" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getGrowTime">
|
|
<code class="descname">getGrowTime</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#getGrowTime" 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>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the amount of time in seconds it takes to execute the <em>grow()</em> Netscript function on the target server.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getweakentime">
|
|
<h2>getWeakenTime<a class="headerlink" href="#getweakentime" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getWeakenTime">
|
|
<code class="descname">getWeakenTime</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span><a class="headerlink" href="#getWeakenTime" 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>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of target server</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the amount of time in seconds it takes to execute the <em>weaken()</em> Netscript function on the target server.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getscriptincome">
|
|
<h2>getScriptIncome<a class="headerlink" href="#getscriptincome" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getScriptIncome">
|
|
<code class="descname">getScriptIncome</code><span class="sig-paren">(</span><span class="optional">[</span><em>scriptname</em><span class="optional">]</span><span class="optional">[</span>, <em>hostname/ip</em><span class="optional">]</span><span class="optional">[</span>, <em>args...</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#getScriptIncome" 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>scriptname</strong> (<em>string</em>) -- Filename of script</li>
|
|
<li><strong>hostname/ip</strong> (<em>string</em>) -- Server on which script is running</li>
|
|
<li><strong>args...</strong> -- Arguments that the script is running with</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the amount of income the specified script generates while online (when the game is open, does not apply for offline income).
|
|
Remember that a script is uniquely identified by both its name and its arguments. So for example if you ran a script with the arguments
|
|
"foodnstuff" and "5" then in order to use this function to get that script's income you must specify those same arguments in the same order
|
|
in this function call.</p>
|
|
<p>This function can also be called with no arguments. If called with no arguments, then this function will return an array of two values. The
|
|
first value is the total income ($ / second) of all of your active scripts (scripts that are currently running on any server). The second value
|
|
is the total income ($ / second) that you've earned from scripts since you last installed Augmentations.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getscriptexpgain">
|
|
<h2>getScriptExpGain<a class="headerlink" href="#getscriptexpgain" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getScriptExpGain">
|
|
<code class="descname">getScriptExpGain</code><span class="sig-paren">(</span><span class="optional">[</span><em>scriptname</em><span class="optional">]</span><span class="optional">[</span>, <em>hostname/ip</em><span class="optional">]</span><span class="optional">[</span>, <em>args...</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#getScriptExpGain" 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>scriptname</strong> (<em>string</em>) -- Filename of script</li>
|
|
<li><strong>hostname/ip</strong> (<em>string</em>) -- Server on which script is running</li>
|
|
<li><strong>args...</strong> -- Arguments that the script is running with</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the amount of hacking experience the specified script generates while online (when the game is open, does not apply for offline experience gains).
|
|
Remember that a script is uniquely identified by both its name and its arguments.</p>
|
|
<p>This function can also return the total experience gain rate of all of your active scripts by running the function with no arguments.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="gettimesincelastaug">
|
|
<h2>getTimeSinceLastAug<a class="headerlink" href="#gettimesincelastaug" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getTimeSinceLastAug">
|
|
<code class="descname">getTimeSinceLastAug</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getTimeSinceLastAug" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns the amount of time in milliseconds that have passed since you last installed Augmentations</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="sprintf">
|
|
<h2>sprintf<a class="headerlink" href="#sprintf" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">sprintf</code><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
|
|
<dd><p>See <a class="reference external" href="https://github.com/alexei/sprintf.js">this link</a> for details.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="vsprintf">
|
|
<h2>vsprintf<a class="headerlink" href="#vsprintf" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">vsprintf</code><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
|
|
<dd><p>See <a class="reference external" href="https://github.com/alexei/sprintf.js">this link</a> for details.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="prompt">
|
|
<h2>prompt<a class="headerlink" href="#prompt" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt>
|
|
<code class="descname">prompt</code><span class="sig-paren">(</span><em>txt</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>txt</strong> (<em>string</em>) -- Text to appear in the prompt dialog box</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Prompts the player with a dialog box with two options: "Yes" and "No". This function will return true if the player click "Yes" and
|
|
false if the player clicks "No". The script's execution is halted until the player selects one of the options.</p>
|
|
</dd></dl>
|
|
|
|
<div class="section" id="defining-your-own-functions">
|
|
<h3>Defining your own Functions<a class="headerlink" href="#defining-your-own-functions" title="Permalink to this headline">¶</a></h3>
|
|
<p>Note that the following information is only applicable for Netscript 1.0.
|
|
<a class="reference internal" href="netscriptjs.html"><span class="doc">NetscriptJS (Netscript 2.0)</span></a> allows you to define your functions using native Javascript
|
|
techniques.</p>
|
|
<p>You can define your own functions in Netscript 1.0 using the following syntax:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">function</span> <span class="n">name</span><span class="p">(</span><span class="n">args</span><span class="o">...</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="n">function</span> <span class="n">code</span> <span class="n">here</span><span class="o">...</span>
|
|
<span class="k">return</span> <span class="n">some_value</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Functions should have some return value. Here is an example of defining and using a function:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">function</span> <span class="nb">sum</span><span class="p">(</span><span class="n">values</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="n">res</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">values</span><span class="o">.</span><span class="n">length</span><span class="p">;</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="n">res</span> <span class="o">+=</span> <span class="n">values</span><span class="p">[</span><span class="n">i</span><span class="p">];</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="n">res</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nb">print</span><span class="p">(</span><span class="nb">sum</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">]));</span> <span class="o">//</span><span class="n">Prints</span> <span class="mi">15</span>
|
|
<span class="nb">print</span><span class="p">(</span><span class="nb">sum</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">]));</span> <span class="o">//</span><span class="n">Prints</span> <span class="mi">11</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>For those with experience in other languages, especially Javascript, it may be important to note that
|
|
function declarations are not hoisted and must be declared BEFORE you use them.
|
|
For example, the following will cause an error saying <cite>variable hello not defined</cite>:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="n">hello</span><span class="p">());</span>
|
|
|
|
<span class="n">function</span> <span class="n">hello</span><span class="p">()</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="s2">"world"</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The following will work fine:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">function</span> <span class="n">hello</span><span class="p">()</span> <span class="p">{</span>
|
|
<span class="k">return</span> <span class="s2">"world"</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="nb">print</span><span class="p">(</span><span class="n">hello</span><span class="p">());</span> <span class="o">//</span><span class="n">Prints</span> <span class="n">out</span> <span class="s2">"world"</span>
|
|
</pre></div>
|
|
</div>
|
|
<p><strong>Note about variable scope in functions:</strong></p>
|
|
<p>Functions can access "global" variables declared outside of the function's scope. However, they cannot change the value of any "global" variables.
|
|
Any changes to "global" variables will only be applied locally to the function.</p>
|
|
<p>The following example shows that any change to a "global" variable
|
|
from inside a function only applies in the function's local scope:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">function</span> <span class="n">foo</span><span class="p">()</span> <span class="p">{</span>
|
|
<span class="n">i</span> <span class="o">=</span> <span class="mi">5</span><span class="p">;</span>
|
|
<span class="k">return</span> <span class="s2">"foo"</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="nb">print</span><span class="p">(</span><span class="n">i</span><span class="p">);</span> <span class="o">//</span><span class="n">Prints</span> <span class="mi">0</span>
|
|
<span class="n">foo</span><span class="p">();</span>
|
|
<span class="nb">print</span><span class="p">(</span><span class="n">i</span><span class="p">);</span> <span class="o">//</span><span class="n">Prints</span> <span class="mi">0</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Furthermore, this also means that any variable that is first defined inside a
|
|
function will NOT be accessible outside of the function as shown in the following example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">function</span> <span class="nb">sum</span><span class="p">(</span><span class="n">values</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="n">res</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="k">for</span> <span class="p">(</span><span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">values</span><span class="o">.</span><span class="n">length</span><span class="p">;</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="n">res</span> <span class="o">+=</span> <span class="n">values</span><span class="p">[</span><span class="n">i</span><span class="p">];</span>
|
|
<span class="p">}</span>
|
|
<span class="k">return</span> <span class="n">res</span><span class="p">;</span>
|
|
<span class="p">}</span>
|
|
<span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>results in the following runtime error:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">Script</span> <span class="n">runtime</span> <span class="n">error</span><span class="p">:</span>
|
|
<span class="n">Server</span> <span class="n">Ip</span><span class="p">:</span> <span class="mf">75.7</span><span class="o">.</span><span class="mf">4.1</span>
|
|
<span class="n">Script</span> <span class="n">name</span><span class="p">:</span> <span class="n">test</span><span class="o">.</span><span class="n">script</span>
|
|
<span class="n">Args</span><span class="p">:[]</span>
|
|
<span class="n">variable</span> <span class="n">res</span> <span class="ow">not</span> <span class="n">defined</span>
|
|
</pre></div>
|
|
</div>
|
|
<p><strong>Other Notes about creating your own functions:</strong></p>
|
|
<p>Defining a function does not create a Javascript function object in the underlying game code. This means that you cannot use any function
|
|
you create in functions such as <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort">Array.sort()</a> (not yet at least, I'll try to make it work in the future).</p>
|
|
</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="netscriptjs.html"> NetscriptJS (Netscript 2.0)</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="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 current"><a class="current reference internal" href="#"> Basic Functions</a><ul>
|
|
<li class="toctree-l3"><a class="reference internal" href="#hack">hack</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#grow">grow</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#weaken">weaken</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="#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="#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="#ftpcrack">ftpcrack</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#relaysmtp">relaysmtp</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#httpworm">httpworm</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#sqlinject">sqlinject</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#run">run</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#exec">exec</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#spawn">spawn</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#kill">kill</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#killall">killall</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#exit">exit</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#scp">scp</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#ls">ls</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#ps">ps</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#hasrootaccess">hasRootAccess</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#gethostname">getHostname</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#gethackinglevel">getHackingLevel</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#gethackingmultipliers">getHackingMultipliers</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#gethacknetmultipliers">getHacknetMultipliers</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getservermoneyavailable">getServerMoneyAvailable</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getservermaxmoney">getServerMaxMoney</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getservergrowth">getServerGrowth</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getserversecuritylevel">getServerSecurityLevel</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getserverbasesecuritylevel">getServerBaseSecurityLevel</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getserverminsecuritylevel">getServerMinSecurityLevel</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getserverrequiredhackinglevel">getServerRequiredHackingLevel</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getservernumportsrequired">getServerNumPortsRequired</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getserverram">getServerRam</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#serverexists">serverExists</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#fileexists">fileExists</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#isrunning">isRunning</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getnexthacknetnodecost">getNextHacknetNodeCost</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#purchasehacknetnode">purchaseHacknetNode</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="#getpurchasedservers">getPurchasedServers</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="#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="#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="#scriptkill">scriptKill</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getscriptname">getScriptName</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getscriptram">getScriptRam</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#gethacktime">getHackTime</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getgrowtime">getGrowTime</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getweakentime">getWeakenTime</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getscriptincome">getScriptIncome</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getscriptexpgain">getScriptExpGain</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#gettimesincelastaug">getTimeSinceLastAug</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#sprintf">sprintf</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#vsprintf">vsprintf</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#prompt">prompt</a><ul>
|
|
<li class="toctree-l4"><a class="reference internal" href="#defining-your-own-functions">Defining your own Functions</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</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"><a class="reference internal" href="netscriptbladeburnerapi.html"> Bladeburner API</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l1"><a class="reference internal" href="terminal.html"> Terminal</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="shortcuts.html"> Keyboard Shortcuts</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="changelog.html"> Changelog</a></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="netscriptscriptarguments.html" title="Netscript Script Arguments"
|
|
>previous</a> |
|
|
<a href="netscriptadvancedfunctions.html" title="Netscript Advanced Functions"
|
|
>next</a> |
|
|
<a href="genindex.html" title="General Index"
|
|
>index</a>
|
|
</div>
|
|
<div role="note" aria-label="source link">
|
|
<br/>
|
|
<a href="_sources/netscriptfunctions.rst.txt"
|
|
rel="nofollow">Show Source</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="right">
|
|
|
|
<div class="footer" role="contentinfo">
|
|
© 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> |