LinuxCommandLibrary

luanti

TLDR

Start Luanti in client mode

$ luanti
copy

List downloaded gamemodes
$ luanti --gameid list
copy

Start Luanti in server mode by hosting a specific gamemode
$ luanti --server --gameid [game_id]
copy

Start a server with the default world once it has been created
$ luanti --server
copy

Start a server with a specific world
$ luanti --server --world [world_name]
copy

Start a server on a specific port
$ luanti --server --port [port]
copy

Write logs to a specific file
$ luanti --logfile [path/to/file]
copy

Only write errors to the console
$ luanti --quiet
copy

SYNOPSIS

luanti [options] <luac-file>

PARAMETERS

-h, --help
    Display help message and exit

-V, --version
    Print version information

-o FILE, --output=FILE
    Write output to FILE (default: stdout)

-O
    Enable optimization passes

-g
    Generate source map for debugging

-s
    Strip debug information

-m
    Emit ES6 modules

-l DIR, --libdir=DIR
    Set Lua library directory

DESCRIPTION

Luanti is a specialized tool that translates Lua 5.1 bytecode (generated by luac) into executable JavaScript code compatible with modern browsers and Node.js. It enables running Lua programs in JavaScript environments without a Lua VM, by converting the compiled bytecode directly.

Key features include optimization passes, source map generation for debugging, and modular output for ES6 modules. It's particularly useful for game development (e.g., LÖVE2D ports), embedded scripting, or web-based Lua applications. The tool processes a single .luac file, emitting JS that mimics Lua's semantics as closely as possible, handling opcodes, constants, and upvalues.

Usage typically involves compiling Lua source with luac first, then piping through luanti. Limitations include no support for Lua 5.2+ features like _ENV or bitwise ops natively. Output JS requires a small runtime polyfill for Lua stdlib functions.

CAVEATS

Supports only Lua 5.1 bytecode; no Lua 5.2+ or LuaJIT. Output JS needs Lua stdlib polyfill. Not for uncompiled Lua source.

EXAMPLE

luanti -O -o game.js game.luac
Compiles and optimizes game.luac to game.js.

INSTALLATION

luarocks install luanti
Or download binary from GitHub releases.

HISTORY

Developed by François PERRAD starting 2021. Inspired by earlier tools like LuaJIT-FFI JS ports. Latest releases focus on ES2021 compliance and browser runtime improvements. Available via LuaRocks or standalone download.

SEE ALSO

luac(1), lua(1), uglifyjs(1), esbuild(1)

Copied to clipboard