Skip to content

LuaJIT and FFI

By default scripts run in a sandboxed environment table:

  • FFI off (default): no ffi, require("ffi") errors, package.loadlib cleared.
  • FFI on (Enable FFI switch, config key Scripts.<name>.FfiEnabled): full LuaJIT FFI.

The standard Lua io library is available with FFI off. Use aqua.script_dir() to build paths for files owned by your script. Persistent settings already use aqua.config.set and aqua.config.save; a separate storage API is unnecessary.

LuaJIT is on by default (luaJIT_setmode(... MODE_ON) when the script state is created). Hot loops and numeric code run compiled; leave it on unless you have a specific reason to call jit.off() yourself.

Check status from a script:

local on, status = jit.status()
print("jit.status() =", on, status, jit.version, jit.arch)

See Working with FFI for realistic use cases and risks.