Standard Library

Luak implements the current Lua standard library as shared Kotlin, one class per library under org.basaltmc.luak.lib. Every library below runs identically on every target.

Library Class Covers
Base BaseLib print, type, pairs/ipairs, pcall/error, metatables (setmetatable, getmetatable, rawget, rawset)
Package PackageLib require, module loading and the package path
Table TableLib insert, remove, sort, concat, and table.pack/unpack
String StringLib Formatting, pattern matching, and byte-oriented string operations
Coroutine CoroutineLib create, resume, yield, wrap, status
Math MathLib Integer and float arithmetic, trigonometry, random number generation
Utf8 Utf8Lib utf8.char, utf8.codepoint, utf8.len, and UTF-8 aware iteration
Io IoLib io.open, io.lines, io.tmpfile, file handles: shared across every target, not JVM-only
Os OsLib Time, date, environment variables, and process control where the host allows it

bit32 is deliberately not among them: real Lua deprecated it in 5.3 and removed it in 5.4, since native bitwise operators cover the same ground once integers are 64 bits wide. Bit32Lib still exists for an embedder that specifically wants it back.

Loading it

LuaPlatform.standardGlobals() loads all nine at once by calling globals.load(...) with each library in turn. To load a subset, do the same by hand with only the classes a script actually needs.

import org.basaltmc.luak.Globals
import org.basaltmc.luak.lib.BaseLib
import org.basaltmc.luak.lib.StringLib
import org.basaltmc.luak.lib.TableLib

// A Globals with no io, no os, no package.loadlib: safe to hand a script author.
val globals = Globals()
globals.load(BaseLib())
globals.load(TableLib())
globals.load(StringLib())

Behavior differs only where the host requires it, see Platform Support and Limitations for the exact capability matrix across JVM, Native, JS and Wasm.