omniLua docs
How to run Lua with omniLua — on the command line, embedded in a Rust program, or in the browser. Start here, then jump to a guide for whatever you're building.
Install
Pick the surface you need. All three run the same Lua.
command lineshell
$ cargo install omnilua-cli # installs the `omnilua` binary
embed in RustCargo.toml
omnilua = "0.4"
browser / Nodeshell
$ npm install omnilua
Your first embed
Create a Lua state, register a Rust function, and run a script:
main.rsrust
use omnilua::Lua; let lua = Lua::new(); let greet = lua.create_function(|_, name: String| Ok(format!("hello, {name}")))?; lua.globals().set("greet", greet)?; lua.load(r#"print(greet("omniLua"))"#).exec()?; // hello, omniLua
To run Lua snippets without installing anything, use the playground — it runs all five versions in the browser.
Guides
Each guide covers one thing you might build.
- Game scripting — embed omniLua in your engine and keep Lua working when the game ships to the browser.
- Lua in the browser — run Lua in a web page or Node from the npm package.
- Embedding in Rust — the API: functions, userdata, tables, errors.
- Sandboxing scripts — run untrusted scripts with CPU and memory limits.
- Coming from mlua — what maps across, and what differs.
- Choosing a version — pick among Lua 5.1–5.5 and know what changes.