9aa3aa9d47
Bumps [certifi](https://github.com/certifi/python-certifi) from 2023.7.22 to 2024.7.4. - [Commits](https://github.com/certifi/python-certifi/compare/2023.07.22...2024.07.04) --- updated-dependencies: - dependency-name: certifi dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> |
||
---|---|---|
.github | ||
docs | ||
docs_source | ||
lihzahrd | ||
.gitattributes | ||
.gitignore | ||
LICENSE.txt | ||
poetry.lock | ||
publish.bat | ||
pyproject.toml | ||
README.md |
lihzahrd
A Terraria 1.4.4.9 world parser in Python.
You can use this package to get programmer-friendly data from a Terraria world!
Installation
Use your favourite Python package manager to install lihzahrd
:
-
Venv + Pip
$ source .venv/bin/activate $ pip install lihzahrd
-
Poetry
$ poetry add lihzahrd
-
And more!
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.
Warning
Loading maliciously designed Terraria worlds can drain system resources, crash the interpreter, or possibly do more evil things!
Make sure you trust the worlds you are parsing!
Documentation
The documentation is available here.
If you know something that is missing in the documentation, please let me know with an issue!
PyPy
lihzahrd
is compatible with PyPy, an alternative implementation on 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
- The TEdit World Parser, the most accurate source currently available.
- The tModLoader wiki, containing lists of all possible IDs.
- The Terrafirma world documentation, accurate for old worlds (version <69)
- The 1.3.x.x world documentation, a bit incomplete, but an useful source nevertheless.
- A JS World Parser on GitHub.
- A Background Guide on Steam that displays all possible world backgrounds.
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
- flyingsnake, a map renderer using this package