I was working on this a while ago and haven’t found much time for it lately, but I thought it could be interesting to some people. It is a fork of Lua that implements the PICO-8 dialect.
If you know how to embed Lua somewhere, then there are chances that you can embed PICO-8 compatible Lua instead! I use it for an unfinished toy emulator project.
- short if syntax (on one line)
- short print syntax (? at the beginning of a line)
- compound assignment operators: += /= etc.
- C style not equal operator: !=
- C++ style comments with //
- fixed-point arithmetic with overflows, infinity etc.
- the PICO-8 math library (shr, atan2, flr etc.)
- binary literals: 0b1001001.10010
- works in Windows and Linux, and probably in OS X too
The usual approach to the language extensions is through code parsing and patching. For instance, replacing all occurrences of <something>+=<blah> with <something>=<something>+(<blah>). This is what PICO-8 itself does, which is why it still has the occasional weird parsing issues (you can write x=0y=1 but not x+=0y=1). My approach is to implement these extensions in the Lua parser instead, which is elegant, more robust, and gives better error reporting.
It’s on GitHub: https://github.com/samhocevar/z8lua
Here is a z8lua session in my terminal; you can see familiar PICO-8 syntax in here:
[Please log in to post a comment]