Skip to content
forked from lua/lua

🧩 A Lua fork that supports PICO-8 syntax extensions and zero-based tables, part of ZEPTO-8

Notifications You must be signed in to change notification settings

samhocevar/z8lua

This branch is 158 commits ahead of, 2945 commits behind lua/lua:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

4a7089e · Nov 14, 2024
Feb 13, 2020
Jan 20, 2024
Feb 13, 2020
Feb 12, 2020
Jan 20, 2024
Jan 21, 2024
Apr 12, 2013
Apr 12, 2013
Apr 12, 2013
Jan 17, 2024
Jul 9, 2013
Jan 21, 2024
Apr 25, 2020
Apr 12, 2013
Sep 27, 2019
Sep 27, 2019
Feb 12, 2020
Apr 25, 2020
Apr 12, 2013
Nov 8, 2013
Apr 12, 2013
Apr 12, 2013
Apr 12, 2013
Apr 12, 2013
Feb 12, 2020
Apr 12, 2013
Feb 13, 2020
Apr 12, 2013
Jan 17, 2024
May 5, 2020
Apr 12, 2013
Apr 12, 2013
Apr 12, 2013
Apr 12, 2013
Apr 12, 2013
Jan 21, 2024
Jan 21, 2024
Apr 25, 2020
May 5, 2020
Apr 12, 2013
May 6, 2020
Apr 12, 2013
Nov 14, 2024
Feb 17, 2020
Apr 23, 2020
Apr 12, 2013
Apr 12, 2013
Jan 17, 2024
Sep 5, 2019
Aug 30, 2013
May 7, 2014
Jan 6, 2018
Apr 12, 2013
Apr 25, 2020
Apr 25, 2020
Jul 4, 2020
Nov 14, 2024
Jan 21, 2024
Feb 13, 2020
Apr 12, 2013
Apr 12, 2013
Jan 21, 2024
Jan 21, 2024
Apr 12, 2013
Apr 12, 2013
Jan 17, 2024
Jan 20, 2024

Repository files navigation

z8lua

This is a fork of Lua that implements the PICO-8 dialect and adds useful features for emulator implementations.

Branches

The main zepto8 branch is a composite branch built from several feature branches. Please try to submit patches and PRs against the corresponding feature branch instead of zepto8.

There are three main feature branches:

  • pico8: this is a “clean” branch that only implements the PICO-8 syntax and type system, with no extra fancy features; a good start if you’re writing your own emulator.
  • eris: a branch imported from the eris persistence patch with bug fixes and improvements (my pull requests have received little attention so far); this library provides serialisable snapshots of the Lua state (quite useful for emulators).
  • oua: experimental branch allowing to switch on-the-fly to zero-based indices in Lua, using the base(0) function and back with base(1). I call this the Oua language.

PICO-8 features

  • short if syntax (on one line)
  • short print syntax (?"hello")
  • 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, Linux, OS X, and many embedded systems

Limitations

  • Lua functions that rely on the PICO-8 state, particularly the VM memory, are beyond the scope of this software; for a more complete PICO-8 implementation, see the zepto8 emulator which is based on z8lua. The only exceptions are the @, % and $ operators (see next section).
  • the ^ (power) operator is implemented using floating point, which is inelegant and a potential performance issue, and which also means the results are not bit-by-bit equivalent to the original PICO-8.

API extensions

LUA_API void lua_setpico8memory (lua_State *L, unsigned char const *p);

Provide the Lua VM with a 64-KiB address space for use with the @, % and $ operators (shorthands for peek, peek2, and peek4). Otherwise these operators will always return 0.

About

🧩 A Lua fork that supports PICO-8 syntax extensions and zero-based tables, part of ZEPTO-8

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 96.0%
  • C++ 3.2%
  • Makefile 0.8%