Python build tools for the PICO-8. MIT License.
Go to file
Robert Miles 4ca6b1c7a0 Initial commit 2018-07-13 08:34:01 -04:00
.gitignore Initial commit 2018-07-13 08:34:01 -04:00
README.md Initial commit 2018-07-13 08:34:01 -04:00
__init__.py Initial commit 2018-07-13 08:34:01 -04:00
preprocessor.py Initial commit 2018-07-13 08:34:01 -04:00

README.md

p8btools - Build tools for PICO-8

Submodule in, and you can use the submodule as a python module.

Use a Makefile like so:

NAME:=blazzle
SRC:=$(wildcard *.lua)
$(NAME).p8: $(SRC)
	python combine.py $(NAME).p8 base.p8 $(SRC)

.PHONY: clean
clean:
	rm $(NAME).p8

A combine.py file like so:

import p8btools,argparse,io

parser = argparse.ArgumentParser(prog="python combine.py",description="Combines a lua file into a .p8 cart.")
parser.add_argument("result",help="The filename for the resulting cart.")
parser.add_argument("p8cart",help="A .p8 cart.")
parser.add_argument("luafile",help="The lua file to inject into the .p8 cart.",nargs="+")
args = parser.parse_args()

cart = p8btools.Cart(args.p8cart)
t = ""
for luafile in args.luafile:
	lua = p8btools.LuaCode(luafile)
	lua.parse()
	t += lua.text
	t += "\n"
cart.lua = t.rstrip()
with io.open(args.result,"w",encoding="utf-8") as f:
	f.write(cart.fulltext)

and a base.p8 like so:

pico-8 cartridge // http://www.pico-8.com
version 16
__lua__