mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-29 19:13:49 +01:00
292 lines
19 KiB
HTML
292 lines
19 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 Hacknet Node API — 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 Trade Information eXchange (TIX) API" href="netscriptixapi.html" />
|
|
<link rel="prev" title="Netscript Advanced Functions" href="netscriptadvancedfunctions.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="netscriptadvancedfunctions.html" title="Netscript Advanced Functions"
|
|
accesskey="P">previous</a> |
|
|
<a href="netscriptixapi.html" title="Netscript Trade Information eXchange (TIX) API"
|
|
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-hacknet-node-api">
|
|
<h1>Netscript Hacknet Node API<a class="headerlink" href="#netscript-hacknet-node-api" title="Permalink to this headline">¶</a></h1>
|
|
<p>Netscript provides the following API for accessing and upgrading your Hacknet Nodes
|
|
through scripts.</p>
|
|
<p>Note that none of these functions will write to the script's logs. If you want
|
|
to see what your script is doing you will have to print to the logs yourself.</p>
|
|
<div class="section" id="hacknetnodes">
|
|
<h2>hacknetnodes<a class="headerlink" href="#hacknetnodes" title="Permalink to this headline">¶</a></h2>
|
|
<blockquote>
|
|
<div><em>hacknetnodes</em> is a special variable. It is an array that maps to the player's
|
|
Hacknet Nodes. The Hacknet Nodes are accessed through indexed. These indexes
|
|
correspond to the number at the end of the name of the Hacknet Node. For example,
|
|
the first Hacknet Node you purchase will have the name "hacknet-node-0" and can be
|
|
accessed using <em>hacknetnodes[0]</em>. The fourth Hacknet Node you purchase will have the name
|
|
"hacknet-node-3" and can be accessed using <em>hacknetnodes[3]</em>.</div></blockquote>
|
|
</div>
|
|
<div class="section" id="hacknet-node-member-variables">
|
|
<h2>Hacknet Node Member Variables<a class="headerlink" href="#hacknet-node-member-variables" title="Permalink to this headline">¶</a></h2>
|
|
<p>The following is a list of member variables for a Hacknet Node object. These variables are read-only, which means you cannot assign
|
|
a value to these.</p>
|
|
<p>Note that these must be called on an element inside the <em>hacknetnodes</em> array, not the array itself.</p>
|
|
<dl class="function">
|
|
<dt id="hacknetnodes[i].level">
|
|
<code class="descclassname">hacknetnodes[i].</code><code class="descname">level</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hacknetnodes[i].level" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns the level of the corresponding Hacknet Node</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="hacknetnodes[i].ram">
|
|
<code class="descclassname">hacknetnodes[i].</code><code class="descname">ram</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hacknetnodes[i].ram" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns the amount of RAM on the corresponding Hacknet Node</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="hacknetnodes[i].cores">
|
|
<code class="descclassname">hacknetnodes[i].</code><code class="descname">cores</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hacknetnodes[i].cores" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns the number of cores on the corresponding Hacknet Node</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="hacknetnodes[i].totalMoneyGenerated">
|
|
<code class="descclassname">hacknetnodes[i].</code><code class="descname">totalMoneyGenerated</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hacknetnodes[i].totalMoneyGenerated" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns the total amount of money that the corresponding Hacknet Node has earned</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="hacknetnodes[i].onlineTimeSeconds">
|
|
<code class="descclassname">hacknetnodes[i].</code><code class="descname">onlineTimeSeconds</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hacknetnodes[i].onlineTimeSeconds" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns the total amount of time (in seconds) that the corresponding Hacknet Node has existed</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="hacknetnodes[i].moneyGainRatePerSecond">
|
|
<code class="descclassname">hacknetnodes[i].</code><code class="descname">moneyGainRatePerSecond</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hacknetnodes[i].moneyGainRatePerSecond" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns the amount of income that the corresponding Hacknet Node earns</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="hacknet-node-methods">
|
|
<h2>Hacknet Node Methods<a class="headerlink" href="#hacknet-node-methods" title="Permalink to this headline">¶</a></h2>
|
|
<p>The following is a list of supported functions/methods for a Hacknet Node object.</p>
|
|
<p>Note that these must be called on an element inside the <em>hacknetnodes</em> array, not the
|
|
array itself.</p>
|
|
<dl class="function">
|
|
<dt id="hacknetnodes[i].upgradeLevel(n);">
|
|
<code class="descclassname">hacknetnodes[i].</code><code class="descname">upgradeLevel(n);</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hacknetnodes[i].upgradeLevel(n);" 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>n</strong> (<em>number</em>) -- Number of levels to upgrade. Must be positive. Rounded to nearest integer</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Tries to upgrade the level of the corresponding Hacknet Node <em>n</em> times. Returns true if the
|
|
Hacknet Node's level is successfully upgraded <em>n</em> times or up to the max level (200), and false
|
|
otherwise.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="hacknetnodes[i].upgradeRam">
|
|
<code class="descclassname">hacknetnodes[i].</code><code class="descname">upgradeRam</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hacknetnodes[i].upgradeRam" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Tries to upgrade the amount of RAM on the corresponding Hacknet Node. Returns true if the RAM is
|
|
successfully upgraded and false otherwise.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="hacknetnodes[i].upgradeCore">
|
|
<code class="descclassname">hacknetnodes[i].</code><code class="descname">upgradeCore</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hacknetnodes[i].upgradeCore" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Tries to purchase an additional core for the corresponding Hacknet Node. Returns true if the
|
|
additional core is successfully purchased, and false otherwise.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="hacknetnodes[i].getLevelUpgradeCost(n);">
|
|
<code class="descclassname">hacknetnodes[i].</code><code class="descname">getLevelUpgradeCost(n);</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hacknetnodes[i].getLevelUpgradeCost(n);" 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>n</strong> (<em>number</em>) -- Number of levels to upgrade. Must be positive. Rounded to nearest integer</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the cost of upgrading the specified Hacknet Node by <em>n</em> levels</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="hacknetnodes[i].getRamUpgradeCost">
|
|
<code class="descclassname">hacknetnodes[i].</code><code class="descname">getRamUpgradeCost</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hacknetnodes[i].getRamUpgradeCost" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns the cost of upgrading the RAM of the specified Hacknet Node. Upgrading a Node's RAM doubles it.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="hacknetnodes[i].getCoreUpgradeCost">
|
|
<code class="descclassname">hacknetnodes[i].</code><code class="descname">getCoreUpgradeCost</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hacknetnodes[i].getCoreUpgradeCost" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns the cost of upgrading the number of cores of the specified Hacknet Node. Upgrading a Node's
|
|
number of cores adds one additional core.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="example-s">
|
|
<h2>Example(s)<a class="headerlink" href="#example-s" title="Permalink to this headline">¶</a></h2>
|
|
<p>The following is an example of one way a script can be used to automate the purchasing and upgrading of Hacknet Nodes.
|
|
This script purchases new Hacknet Nodes until the player has four. Then, it iteratively upgrades each of those four Hacknet
|
|
Nodes to a level of at least 75, RAM to at least 8GB, and number of cores to at least 2:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">//</span><span class="n">Purchase</span> <span class="mi">4</span> <span class="n">Hacknet</span> <span class="n">Nodes</span>
|
|
<span class="k">while</span><span class="p">(</span><span class="n">hacknetnodes</span><span class="o">.</span><span class="n">length</span> <span class="o"><</span> <span class="mi">4</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="n">purchaseHacknetNode</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="o">//</span><span class="n">Upgrade</span> <span class="nb">all</span> <span class="mi">4</span> <span class="n">Hacknet</span> <span class="n">Nodes</span> <span class="n">to</span> <span class="n">at</span> <span class="n">least</span> <span class="n">level</span> <span class="mi">75</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">4</span><span class="p">;</span> <span class="n">i</span> <span class="o">=</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">while</span> <span class="p">(</span><span class="n">hacknetnodes</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">level</span> <span class="o"><=</span> <span class="mi">75</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="n">hacknetnodes</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">upgradeLevel</span><span class="p">(</span><span class="mi">5</span><span class="p">);</span>
|
|
<span class="n">sleep</span><span class="p">(</span><span class="mi">10000</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="o">//</span><span class="n">Upgrade</span> <span class="n">RAM</span> <span class="n">on</span> <span class="nb">all</span> <span class="n">Hacknet</span> <span class="n">Nodes</span> <span class="n">to</span> <span class="mi">8</span><span class="n">GB</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">4</span><span class="p">;</span> <span class="n">i</span> <span class="o">=</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">while</span> <span class="p">(</span><span class="n">hacknetnodes</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">ram</span> <span class="o"><</span> <span class="mi">8</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="n">hacknetnodes</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">upgradeRam</span><span class="p">();</span>
|
|
<span class="n">sleep</span><span class="p">(</span><span class="mi">10000</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="o">//</span><span class="n">Upgrade</span> <span class="n">cores</span> <span class="n">on</span> <span class="nb">all</span> <span class="n">Hacknet</span> <span class="n">Nodes</span> <span class="n">to</span> <span class="mi">2</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">4</span><span class="p">;</span> <span class="n">i</span> <span class="o">=</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="k">while</span> <span class="p">(</span><span class="n">hacknetnodes</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">cores</span> <span class="o"><</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="n">hacknetnodes</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">upgradeCore</span><span class="p">();</span>
|
|
<span class="n">sleep</span><span class="p">(</span><span class="mi">10000</span><span class="p">);</span>
|
|
<span class="p">}</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sidebar">
|
|
<h3>Table Of Contents</h3>
|
|
<p class="caption"><span class="caption-text">Contents:</span></p>
|
|
<ul class="current">
|
|
<li class="toctree-l1 current"><a class="reference internal" href="netscript.html"> Netscript</a><ul class="current">
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptdatatypes.html"> Data Types and Variables</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptoperators.html"> Operators</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptloopsandconditionals.html"> Loops and Conditionals</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptscriptarguments.html"> Script Arguments</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html"> Basic Functions</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptadvancedfunctions.html"> Advanced Functions</a></li>
|
|
<li class="toctree-l2 current"><a class="current reference internal" href="#"> Hacknet Node API</a><ul>
|
|
<li class="toctree-l3"><a class="reference internal" href="#hacknetnodes">hacknetnodes</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#hacknet-node-member-variables">Hacknet Node Member Variables</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#hacknet-node-methods">Hacknet Node Methods</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#example-s">Example(s)</a></li>
|
|
</ul>
|
|
</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>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
<div role="search">
|
|
<h3 style="margin-top: 1.5em;">Search</h3>
|
|
<form class="search" action="search.html" method="get">
|
|
<input type="text" name="q" />
|
|
<input type="submit" value="Go" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="footer-wrapper">
|
|
<div class="footer">
|
|
<div class="left">
|
|
<div role="navigation" aria-label="related navigaton">
|
|
<a href="netscriptadvancedfunctions.html" title="Netscript Advanced Functions"
|
|
>previous</a> |
|
|
<a href="netscriptixapi.html" title="Netscript Trade Information eXchange (TIX) API"
|
|
>next</a> |
|
|
<a href="genindex.html" title="General Index"
|
|
>index</a>
|
|
</div>
|
|
<div role="note" aria-label="source link">
|
|
<br/>
|
|
<a href="_sources/netscripthacknetnodeapi.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> |