| Crates.io | pico8-to-lua |
| lib.rs | pico8-to-lua |
| version | 0.1.1 |
| created_at | 2025-05-31 08:34:01.98906+00 |
| updated_at | 2025-07-19 09:26:51.172653+00 |
| description | Converts Pico-8's dialect of Lua to plain Lua |
| homepage | |
| repository | https://github.com/shanecelis/pico8-to-lua |
| max_upload_size | |
| id | 1696187 |
| size | 35,157 |
A library and command line tool to convert Pico-8's dialect of Lua to plain Lua.
cargo add pico8-to-lua
cargo install pico8-to-lua
pico8-to-lua cart.p8 > patched-cart.p8
echo "if (true) x+= 1" | pico8-to-lua -
if true then x = x + (1) end
use pico8_to_lua::patch_lua;
assert_eq!(patch_lua("x += 1"), "x = x + (1)");
use pico8_to_lua::patch_includes;
fn comment_it(path: &str) -> String {
format!("-- INCLUDE '{}'", path)
}
assert_eq!(patch_includes("#include file.p8", comment_it), "-- INCLUDE 'file.p8'");
It's recommended to patch the includes before patching the code in practice because the includes may need patching as well.
This handles most of the Pico-8 dialect. However, it does not handle the rotation operators: '>><' and '<<>'.
Don't go trusting this too much because it is merely a collection of regular expressions and not a full blown language parser like it should be.
This is a port of Ben Wiley's pico8-to-lua Lua tool to Rust. Pico8-to-lua was originally derived from a function in Jez Kabanov's PICOLOVE project.
PICOLOVE is licensed under the Zlib license and so is Wiley's pico8-to-lua and so this project is.