Log In  

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:

P#54527 2018-07-30 07:38 ( Edited 2018-07-30 11:38)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-08-19 15:11 | 0.013s | 2097k | Q:18