Code Monkey home page Code Monkey logo

lihzahrd's Introduction

lihzahrd Available on PyPI

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

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

lihzahrd's People

Contributors

dependabot[bot] avatar dfloer avatar kattusite avatar martinrohrbach avatar martydingo avatar steffo99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

lihzahrd's Issues

Check contents of chests

Hello! I am trying to make a python program to check every chest from the world. However, all I can get in return is, for example: <Chest '' at 3145, 635>. How do I convert this to return the items of the chest?

Support 1.4.4.9

Hiya there,

I have forked this code and incorporated another fork, and a PR here about optimizations & caching, and I have come up with a codebase that supports Terraria 1.4.4.9.

https://github.com/martydingo/lihzahrd/

Would you be interested in a PR, as so we can get the version in PyPi supporting Terraria 1.4.4.9?

world format question

Hi, found this project searching for descriptions of the .wld format. I'm trying to teach myself Rust by parsing .wld files, and your project is very helpful, despite your comments that claim sections to be a mess ๐Ÿ˜„

I don't know if you can answer this, but I'm trying to understand tileframeimportant. from some of the (old) linked documentation, it's explained as this:

Finally, some tile types are marked "Important", and contain texture coordinates, other tiles have their texture coordinates calculated at runtime. Which types are important or not is not stored in the wld document, instead it is up to the client to keep a list.

I don't really understand this. but looking at your code, is it correct to say that the "important" designation only applies to blocks? What's a texture coordinate?


One other thing: I notice in your string parsing routine, you're using ULEB128. How did you determine this was the case? Parsing the world name, it looks like you can get away with reading a byte for the string length (which, in my naive tests, can be no longer than 20), and then just taking this number of subsequent bytes for the string. Is there another place where this strategy doesn't work?

Upgrade for Terraria 1.4.2.3

Describe the feature

Terraria 1.4.2.3 is probably the last version of Terraria. A code update to handle maps from this version would be great.

Reasoning for the implementation

This is the last update that should happen, so it's probably the most important one.

Additional information

N/A

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.