Emit mapping
Fixed order of generated Luau:
--!strictif#pragma strict, or--!nonstrictif#pragma nostrict--!nativeif#pragma native--!optimize Nif#pragma optimize/#pragma optimize Ngame:GetService(...)require(...)(libs and quoted includes that are not the stem)- types (
export type) - constants
- functions / script body
init()if present (Script / LocalScript)
Formatting is StyLua’s job; Luau type checking is luau-analyze’s job.
Operators
Section titled “Operators”| CL++ | Luau |
|---|---|
. property | . |
. instance method call | : |
: protected call | pcall of the method; nil on error |
: type on a name | name: Type |
:: on a call (manual / static method) | : |
:: without a call (static scope) | . |
.: | .. |
null | nil |
post | print |
report | error |
warn | warn |
++ / -- | += 1 / -= 1 |
~> | janitor:Add(..., "Disconnect") |
Patterns used in leaderstats
Section titled “Patterns used in leaderstats”| CL++ | Luau |
|---|---|
string GetPlayerJanitorKey(Player player) | const function GetPlayerJanitorKey(player: Player): string |
player.Name .: "_LeaderstatsJanitor" | player.Name .. "_LeaderstatsJanitor" |
currentValue.Value != newValue | currentValue.Value ~= newValue |
player.FindFirstChild("leaderstats") | player:FindFirstChild("leaderstats") |
static_cast<Folder>(existingFolder) | existingFolder (annotated Folder) |
new Folder(player) | Instance.new("Folder"); folder.Parent = player |
new IntValue(newFolder) | Instance.new("IntValue"); coins.Parent = newFolder |
GetService<Players>() | game:GetService("Players") |
DataService.Server.WaitFor(player) | DataService.Server:WaitFor(player) |
signal::Connect(func (int n) { ... }) | signal:Connect(function(n: number) ... end) |
for (Player player in players.GetPlayers()) | for _, player in players:GetPlayers() do |
game.BindToClose(func () { ... }) | game:BindToClose(function() ... end) |
null / if (existingFolder) | nil / truthy |
observable int coins = 100 | Instance.new("IntValue"); coins.Value = 100 |
coins.OnChange(fn) | coins.Changed:Connect(fn) |
signal~>Connect(fn) | janitor:Add(signal:Connect(fn), "Disconnect") |
signal~>Once(fn) | janitor:Add(signal:Once(fn), "Disconnect") |
signal.Fire(...) | signal:Fire(...) |
obj.GetPropertyChangedSignal("Name") | obj:GetPropertyChangedSignal("Name") |
guard (x) else { return; } | if not (x) then return end |
await expr | __await(expr) |
auto [a, b] = fn(); | local a, b = fn() |
spawn { ... }; | task.spawn(function() ... end) |
parallel { ... }; | task.desynchronize() / task.synchronize() |