dansanderson / picotool

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

p8tool listrawlua fails with "no attribute 'get_raw_data_from_p8_file'" #102

Open hsandt opened 2 years ago

hsandt commented 2 years ago

Error

After upgrading to latest picotool, in the hope that the new Unicode support allows me to work with glyphs, I tried to run p8tool listrawlua myfile.p8 but I got:

Traceback (most recent call last): File "~/.local/bin/p8tool", line 8, in sys.exit(main()) File "~/.local/lib/python3.8/site-packages/pico8/tool.py", line 625, in main return args.func(args) File "~/.local/lib/python3.8/site-packages/pico8/tool.py", line 188, in listrawlua data = game.Game.get_raw_data_from_p8_file(fh, fname) AttributeError: type object 'Game' has no attribute 'get_raw_data_from_p8_file'

Fix

A quick inspection of the code shows me that p8.py now defines a _get_raw_data_from_p8_file (with underscore). So in tool.py, in listrawlua, I replaced game.Game.get_raw_data_from_p8_file with _get_raw_data_from_p8_file, and also imported it at the top with:

from pico8.game.formatter.p8 import _get_raw_data_from_p8_file

Doing this (and reinstalling the tool with pip install --user --force-reinstall .) effectively fixes the Python error and make the command basically work.

Bonus issue

I noticed, however, that my glyph is not correctly transcribed.

🅾️ becomes ユか✽ゆヤま◆ during the listrawlua translation.

A simple p8tool listlua, on the other side, will convert it to underscores: _______ which is the initial issue I had (even with listrawlua) with the previous version of picotool.