DISCLAIMER: I was not a Roblox employee when I made this, so don’t expect anything here to make it in Luau.
This project has been abandoned in favor of Luau!
Hello everyone! For the last two and a half months, I’ve been working on Lunar. Lunar is a superset programming language of Lua 5.1.
That means Lunar can take your existing Lua project, and extend it with Lunar’s features!
This project is still early in development! We are basically releasing a “demo” version of Lunar.
Lunar implements proper classes, self-assignment operators, and lambda expressions. More to come later! You can learn Lunar by reading the language documentation, which has examples too.
Features
Classes
class Account
constructor(name, balance)
self.name = name
self.balance = balance or 0
end
function deposit(credit)
self.balance += credit
end
function withdraw(debit)
self.balance -= debit
end
end
local account = Account.new("Jeff Bezos", 500)
print(account.balance) --> 500
account:deposit(250)
print(account.balance) --> 750
account:withdraw(300)
print(account.balance) --> 450
Self-assignment operators
No more of those annoyingly verbose a = a .. b
! Now you can write a ..= b
instead. ..=
, +=
, -=
, *=
, /=
, and ^=
are all supported.
Lambda expressions
Note: Syntax is debatable and understandably so. All I ask right now is for you to try it out.
local Players = game:GetService("Players")
local minimumAgeLimit = 7
local isNewPlayer = |p| p.AccountAge < minimumAgeLimit -- implicit return, only a single expression
Players.PlayerAdded:Connect(|p| do
if isNewPlayer(p) then
p:Kick("Sorry! Your account must be " .. minimumAgeLimit .. " days or older to be allowed in.")
end
end)
Examples
I created a project in Lunar, which is an object oriented admin script named Commander. Note this is not meant to be production ready at all. It serves two purposes: to test usability of Lunar, and to exist as a case study.
How do I try out Lunar?
Currently we don’t precompile binaries, so you’ll need to follow these instructions. Absolutely do ask questions! I will be compiling these questions and making a wiki for it.
You’ll need a .lunarconfig
file in your project folder so Lunar knows which folder to target! Assuming you have project
and spec
, you should have include = { "project", "spec" }
in your .lunarconfig
file. Also assuming you want the output folder to be named dist
, then you need to add out_dir = "dist"
as well. Both of these variables are required for Lunar.