<h1>Usage guide<aclass="headerlink"href="#usage-guide"title="Permalink to this headline">¶</a></h1>
<divclass="section"id="prerequisites">
<h2>Prerequisites<aclass="headerlink"href="#prerequisites"title="Permalink to this headline">¶</a></h2>
<p>To use <codeclass="docutils literal notranslate"><spanclass="pre">lihzahrd</span></code>, you need Python 3.7 or higher.</p>
<p>That’s it! No other packages are required!</p>
</div>
<divclass="section"id="installing">
<h2>Installing<aclass="headerlink"href="#installing"title="Permalink to this headline">¶</a></h2>
<p>You can download (or update) the package with <codeclass="docutils literal notranslate"><spanclass="pre">pip</span></code> by entering in your terminal:</p>
<h2>Opening a world<aclass="headerlink"href="#opening-a-world"title="Permalink to this headline">¶</a></h2>
<p>To open a Terraria world file named <codeclass="docutils literal notranslate"><spanclass="pre">terra.wld</span></code> located in the current working directory, you should import the
<codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">lihzahrd</span></code> package and then call the <aclass="reference internal"href="world.html#lihzahrd.World.create_from_file"title="lihzahrd.World.create_from_file"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">World.create_from_file()</span></code></a> function:</p>
<h2>Accessing the world properties<aclass="headerlink"href="#accessing-the-world-properties"title="Permalink to this headline">¶</a></h2>
<p>Most of the world properties are accessible directly as attributes of the <aclass="reference internal"href="world.html#lihzahrd.World"title="lihzahrd.World"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">World</span></code></a> object:</p>
<p>You can look at the <aclass="reference internal"href="world.html#lihzahrd.World"title="lihzahrd.World"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">World</span></code></a> class documentation or use an IDE that supports type annotations
(such as <aclass="reference external"href="https://www.jetbrains.com/pycharm/">PyCharm</a>) to find all available attributes.</p>
</div>
<divclass="section"id="accessing-the-tile-data">
<h2>Accessing the tile data<aclass="headerlink"href="#accessing-the-tile-data"title="Permalink to this headline">¶</a></h2>
<p>All <aclass="reference internal"href="tiles.html#lihzahrd.tiles.Tile"title="lihzahrd.tiles.Tile"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">tiles.Tile</span></code></a> are stored in the <aclass="reference internal"href="tiles.html#lihzahrd.tiles.TileMatrix"title="lihzahrd.tiles.TileMatrix"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">tiles.TileMatrix</span></code></a> accessible at the <aclass="reference internal"href="world.html#lihzahrd.World.tiles"title="lihzahrd.World.tiles"><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">World.tiles</span></code></a>
<p>You can access them by using the <codeclass="docutils literal notranslate"><spanclass="pre">tiles</span></code> attribute as a two-dimensional array, where (0, 0) is the top-left block:</p>
<p>You can also use <aclass="reference internal"href="fileutils.html#lihzahrd.fileutils.Coordinates"title="lihzahrd.fileutils.Coordinates"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">fileutils.Coordinates</span></code></a> instead of a <aclass="reference external"href="https://docs.python.org/3.7/library/stdtypes.html#tuple"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">tuple</span></code></a> to fetch a specific tile:</p>
<p>A single <aclass="reference internal"href="tiles.html#lihzahrd.tiles.Tile"title="lihzahrd.tiles.Tile"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">tiles.Tile</span></code></a> has five attributes that you can access:</p>
<li><p><aclass="reference internal"href="tiles.html#lihzahrd.tiles.Tile.liquid"title="lihzahrd.tiles.Tile.liquid"><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">tiles.Tile.liquid</span></code></a>, the <aclass="reference internal"href="tiles.html#lihzahrd.tiles.Liquid"title="lihzahrd.tiles.Liquid"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">tiles.Liquid</span></code></a> present in that tile;</p></li>
<li><p><aclass="reference internal"href="tiles.html#lihzahrd.tiles.Tile.wiring"title="lihzahrd.tiles.Tile.wiring"><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">tiles.Tile.wiring</span></code></a>, the colored wires and actuators (<aclass="reference internal"href="tiles.html#lihzahrd.tiles.Wiring"title="lihzahrd.tiles.Wiring"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">tiles.Wiring</span></code></a>);</p></li>
<li><p><aclass="reference internal"href="tiles.html#lihzahrd.tiles.Tile.extra"title="lihzahrd.tiles.Tile.extra"><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">tiles.Tile.extra</span></code></a>, additional data about the block present at that tile, such as the contents of a chest.</p></li>
</ul>
<p>All of these attributes may be <codeclass="xref py py-const docutils literal notranslate"><spanclass="pre">None</span></code> if the property isn’t applicable for the tile:
for example, <aclass="reference internal"href="tiles.html#lihzahrd.tiles.Tile.block"title="lihzahrd.tiles.Tile.block"><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">tiles.Tile.block</span></code></a> is <codeclass="xref py py-const docutils literal notranslate"><spanclass="pre">None</span></code> if there is no block (“air”) placed there.</p>
</div>
<divclass="section"id="accessing-extra-data">
<h2>Accessing extra data<aclass="headerlink"href="#accessing-extra-data"title="Permalink to this headline">¶</a></h2>
<p>Extra data, such as the content of chests or the text of signs, may be accessed in two different ways:</p>
<ul>
<li><p>Through the <aclass="reference internal"href="tiles.html#lihzahrd.tiles.Tile.extra"title="lihzahrd.tiles.Tile.extra"><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">tiles.Tile.extra</span></code></a> attribute:</p>
<spanclass="c1"># <Chest '' at 2893, 1074></span>
</pre></div>
</div>
</li>
<li><p>Through the various lists available in the <aclass="reference internal"href="world.html#lihzahrd.World"title="lihzahrd.World"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">World</span></code></a> class, such as <aclass="reference internal"href="world.html#lihzahrd.World.chests"title="lihzahrd.World.chests"><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">World.chests</span></code></a>:</p>
<h2>Something else<aclass="headerlink"href="#something-else"title="Permalink to this headline">¶</a></h2>
<p>All information included in a Terraria savefile is parsed in this package and made available in the <aclass="reference internal"href="world.html#lihzahrd.World"title="lihzahrd.World"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">World</span></code></a>
object.</p>
<p>If you couldn’t find what you needed in this short usage guide, check the API Reference or have a look at the
Built with <ahref="http://sphinx-doc.org/">Sphinx</a> using a <ahref="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.