dansanderson / picotool

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

Multiple lua files #22

Closed fmahnke closed 6 years ago

fmahnke commented 7 years ago

Is assembling a cart from multiple lua files supported?

My use case is to separate my reusable code into multiple .lua files, then bring the library code for my different systems into the cart file.

jessemillar commented 7 years ago

Based on my reading of the README file for picotool, there isn't support for multiple .lua files. My tool definitely supports multiple .p8 files though for anyone else that wants a bit more code organization like I did.

fmahnke commented 7 years ago

Thanks! My current solution is to cat the different .lua files together, then use picotool as usual.

This can cause strange errors if I'm not careful, so I'll eventually want something more robust. I'll check out yours.

dansanderson commented 7 years ago

It's easy enough to script simple concatenation with picotool, which sounds like what you're already doing:

cat s1.lua s2.lua s3.lua >/tmp/cat.lua
p8tool build --lua /tmp/cat.lua mycart.p8.png

I have plans for a more robust version of this, but they're elaborate enough plans that I haven't finished it yet. :)

dansanderson commented 6 years ago

p8tool build --lua source.lua now supports source.lua containing a require() statement it in, with elaborate support for that. That'll be the built-in support for multiple Lua files. You can still script your own concatenation method as above, if that's preferred.

jessemillar commented 6 years ago

@dansanderson That sounds awesome and much more robust than my concatenation method.