Lute is a standalone runtime for general-purpose programming in Luau, and a collection of optional extension libraries for Luau embedders to include to expand the capabilities of the Luau scripts in their software.
It is designed to make it readily feasible to use Luau to write any sort of general-purpose programs, including manipulating files, making network requests, opening sockets, and even making tooling that directly manipulates Luau scripts.
Lute also features a standard library of Luau code, called std, that aims to expose a more featureful standard library for general-purpose programming that we hope can be an interface shared across Luau runtimes.
Lute is still very much a work-in-progress, and should be treated as pre-1.0 software without stability guarantees for its API. We would love to hear from you about your experiences working with other Luau or Lua runtimes, and about what sort of functionality is needed to best make Luau accessible and productive for general-purpose programming.
The Lute repository fundamentally contains three sets of libraries. These are as follows:
lute: The core runtime libraries in C++, which provides the basic functionality for general-purpose Luau programming.std: The standard library, which extends those core C++ libraries with additional functionality in Luau.batteries: A collection of useful, standalone Luau libraries that do not depend onlute.
Contributions to any of these libraries are welcome, and we encourage you to open issues or pull requests if you have any feedback or contributions to make.
table.map(table: table, callback: (value: any) -> any): tableTransforms a table with a modifier function applied on every value.
table.map({1, 2, 3}, function(value)
return value * 2
end) -- {2, 4, 6}table.filter(table: table, callback: (value: any) -> boolean): tableFilters a table with a predicate function applied on every value.
table.filter({1, 2, 3}, function(value)
return value % 2 == 0
end) -- {2}table.fold(table: table, callback: (accumulator: any, value: any) -> any, initial: any): anyFolds a table with an accumulator function applied on every value.
table.fold({1, 2, 3}, function(accumulator, value)
return accumulator + value
end, 0) -- 6table.isArray(table: table): booleanChecks if a table is an array.
table.isArray({1, 2, 3}) -- truetable.union(table1: table, table2: table): tableMerges two tables into one.
table.union({1, 2}, {3, 4}) -- {1, 2, 3, 4}
table.union({a = 1}, {b = 2}) -- {a = 1, b = 2}table.count(table: table): numberCounts the number of elements in a table. For arrays use#t, this is useful for dictionaries.
table.count({a = 1, b = 2}) -- 2table.reverse(table: table): tableReverses the order of elements in a table.
table.reverse({1, 2, 3}) -- {3, 2, 1}table.difference(table1: table, table2: table): tableReturns the difference between two tables.
table.difference({1, 2, 3}, {2, 3, 4}) -- {1}table.contains(table: table, value: any): booleanChecks if a table contains a subtable.
table.contains({1, 2, 3}, {2, 3}) -- truetable.set(table: table): tableRemoves duplicate values from a array.
table.set({1, 2, 2, 3}) -- {1, 2, 3}task.delay(time: number|duration, callback: () -> void): voidtask.wait(time: number|duration): voidIdentical to Roblox variants, but can taketime.durationas a parameter.
task.delay(time.duration.seconds(1), function()
print("Hello, world!")
end)task.create(callback: () -> void): task&task.await(task: task): voidCreates a new task.
local myTask = task.create(function()
print("Hello, world!")
return 42
end)
task.await(myTask)
print(myTask.result) -- 42task.awaitAll(task1: task, task2: task, ...): voidAwaits all tasks in a table.
local myTask1 = task.create(function()
return 1
end)
local myTask2 = task.create(function()
return 2
end)
task.awaitAll(myTask1, myTask2)
print(myTask1.result) -- 1
print(myTask2.result) -- 2vector.withx(vector: vector, x: number): vector,vector.withy(vector: vector, y: number): vector,vector.withz(vector: vector, z: number): vectorSets the x component of a vector.
vector.withx(vector.create(1, 2, 3), 4) -- vector.create(4, 2, 3)vector.rotate(vector: vector, angle: number, dimension: string): vectorRotates a vector by an angle.
-- this will rotate the vector 90degrees around the origin over the y-axis
vector.rotate(vector.create(1, 0, 0), math.rad(90), "y")python ./tools/luthier.py fetch lute(Download submodules)python ./tools/luthier.py configure lute --config=debug(Configure the build)python ./tools/luthier.py build lute --config=debug(Build the project)
- Replace
debugwithreleasefor a release build- You may need to replace
pythonwithpython3depending on your system- You may need to add
--c-compiler /usr/bin/clang --cxx-compiler /usr/bin/clang++to theconfigure&buildcommands with your compiler paths.