dansanderson / picotool

Tools and Python libraries for manipulating Pico-8 game files. http://www.lexaloffle.com/pico-8.php
MIT License
367 stars 46 forks source link

Use as a python library #87

Closed BenMcLean closed 2 years ago

BenMcLean commented 2 years ago

It would be nice to have this set up to use as a python library, not just as a command line tool.

I'm inexperienced with Python so I may not be saying the right thing here.

dansanderson commented 2 years ago

Hi @BenMcLean ! picotool is very much intended to be used as a Python library. When you run python setup.py install, it will install the pico8 Python module in your Python libraries. You can import pico8 and do whatever you like. See Building New Tools for a bit more information.

The general idea is you can use the pico8.game.file module to load a cart into a Game object, then you can access and manipulate the various aspects of the cart through rich objects on properties of the Game. You can save the Game object with any changes you've made. You can also use the Game class to create an empty cart from scratch and populate these properties.

Use the docstrings to find out more about the different modules, classes, and functions. I have future plans to write a little manual (there's an empty Sphinx project set up so far), but I want to clear out some bugs and feature requests first. Let me know if you have questions in the meantime.

BenMcLean commented 2 years ago

Thanks for the info. I don't know why I didn't find that "Buililding new tools" section on my own.