1
Fork 0
mirror of https://github.com/Steffo99/lihzahrd.git synced 2024-11-23 08:34:23 +00:00
Terraria world parser in Python
Find a file
2022-02-11 19:46:10 +01:00
docs 📔 Update documentation 2021-06-07 10:16:32 +02:00
docs_source 🧹 Run Black on all files 2022-02-11 18:05:29 +01:00
lihzahrd 📔 Fix docstrings for certain files 2022-02-11 19:44:49 +01:00
.gitattributes Update git data 2019-08-07 14:08:25 +02:00
.gitignore 🧹 Remove __main__.py 2021-06-07 10:16:32 +02:00
LICENSE.txt Create LICENSE.txt 2019-08-13 17:06:24 +02:00
poetry.lock ⬆️ Update dependencies 2022-02-11 19:46:10 +01:00
publish.bat publish: 2.0.0a1 2020-06-10 19:54:56 +02:00
pyproject.toml 🧹 Run Black on all files 2022-02-11 18:05:29 +01:00
README.md 🗒 Update README.md 2021-06-07 10:16:32 +02:00

lihzahrd

A Terraria 1.4.2.3 world parser in Python.

You can use this package to get programmer-friendly data from a Terraria world!

Install with:

pip install lihzahrd

Usage

You can open a world file and get a World object by calling:

import lihzahrd
world = lihzahrd.World.create_from_file("filename.wld")

It will take a while to process: a small Terraria world contains more than 5 million tiles!

Once you have a World object, you can use all data present in the save file by accessing its attributes.

Documentation

The documentation is available here.

It's a bit messy and incomplete, as I still have not figured out the meaning of some data, and the code is in need of some refactoring.

If you know something that isn't present in the documentation, please let me know with an issue!

PyPy

lihzahrd is compatible with PyPy, a faster implementation of Python!

If you think that parsing a world takes too much time, you can use PyPy to reduce the required time by a factor of ~3!

Benchmarks

Time to parse the same large world:

  • CPython took 11.45 s.
  • Pypy took 3.57 s!

Development

To contribute to lihzahrd, you need to have Poetry installed on your PC.

After you've installed Poetry, clone the git repo with the command:

git clone https://github.com/Steffo99/lihzahrd

Then enter the new directory:

cd lihzahrd

And finally install all dependencies and the package:

poetry install

This will create a new virtualenv for the development of the library; you can activate it by typing:

poetry shell

Please note that for compatibility with PyPy, the project needs to target Python 3.6.

Building docs

You can build the docs by entering the docs_source folder and running make html, then committing the whole docs folder.

References used

License

lihzahrd is licensed under the AGPL 3.0. That means you have to publish under the same license the source code of any program you create that uses lihzahrd.

See also