Robert Miles 4ca6b1c7a0 | ||
---|---|---|
.gitignore | ||
README.md | ||
__init__.py | ||
preprocessor.py |
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__