Skip to the text
RoswaalTechnical specification
Draft 0.1
Try Roswaal

Part II · Profiles

11 Luau for Roblox

The profile for Roblox experiences: Luau's types and Roblox's, the class tree, the built-in library, and the files it writes.

Normative · Level 2Draft 0.1

11.1 Overview

Info

This section is informative.

The profile with the id roblox turns graphs into Luau scripts for Roblox experiences, laid out as a Rojo project. It is the profile Roswaal was built for, and its library has 300 built-in nodes. Luau for Lune shares most of it.

11.2 Types and conversions

  • Luau's own types: number, string, boolean, table, function, thread, and nil as a value.
  • Roblox's datatypes, such as Vector3, CFrame and Color3: 48 of them.
  • Every engine class, such as Part and Player: 625 of them.
  • The one conversion: number and string, both ways, as Luau converts them.

From a Luau annotation to a pin type

AnnotationPin type
None, unknown, neverany
A name, such as Model or Vector3That name
A name with ?, such as Model?That name; the pin is marked as possibly missing (§6.1)
A dotted name, such as Module.ConfigThat name
A table type, { … }table
A union, a function type, anything elseany

From pinTypeOf in core/nodes/variables.ts.

11.3 Families of Roblox's types

FamilyTypes
objectEvery engine class.
signalRBXScriptSignal.
tabletable, and any written table type.
functionfunction, and any written function type.
valueEverything else: Luau's other types and Roblox's datatypes, RBXScriptConnection among them.

On a type chip, RBXScript is left off the front of a name (RBXScriptConnection reads Connection), a written table type reads table and a function type function.

11.4 Classes and the hierarchy

The class tree, the classes' summaries and their members come from Roblox's Creator Documentation, generated into Roswaal's source by its build scripts rather than read at run time: 625 classes, 48 datatypes and 507 enums. Every class has one parent, up to Object at the root, and a class connects into any of its ancestors (§6.3).

11.5 The built-in library

CategoryNodesRuns onGlyph
Flow20Bothflow
Events6Roblox onlyevents
Variables7Bothvariables
Values11Bothvalues
Math15Bothmath
Logic10Bothlogic
Strings7Bothstrings
Tables17Bothtables
Roblox Types108Both, and Roblox onlyvector3
Roblox12Roblox onlyengine
Instances26Roblox onlyinstances
Players4Roblox onlyplayers
Networking13Roblox onlynetworking
Modules10Both, and Roblox onlymodules
Lune2Lune onlylune
Time8Roblox onlytime
Threads16Both, and Roblox onlythreads
Debug6Bothdebug
Z-Up Conversions4Roblox onlyconversions

Generated from core/nodes and core/nodeGlyphs.ts. Both means the node works in a Lune graph too (§12). The Roblox Types category is split by datatype, each with a colour and a glyph of its own. A node that starts or ends a flow takes the glyph entry or terminal; Function and Declare Function take function, and Return return, whatever its category.

11.6 What each node compiles to

Every built-in node's page in these docs, such as Print, shows the Luau it compiles to. How values are bound and inlined is §7.2's rule, written as Luau: a value read once is written where it is read, and one read twice in a block becomes a local.

11.7 Scripts, modules, run contexts

Script classRun contextFile written
Scriptabsent, Server or Legacy<name>.server.luau
ScriptClient<name>.client.luau
LocalScriptany<name>.client.luau
ModuleScriptany<name>.luau

Rojo decides what a file becomes in Studio from its name, so the class and run context are written into the name. A module returns what its Module Exports node is given. Where each file goes in the place is the node map's (§9.5), which becomes a Rojo project file.

The file's header

luau
--!strict
-- Generated by Roswaal. Do not edit this file directly;
-- edit Main.nodescript and recompile instead.
-- roswaal-graph: <the graph's id>
-- roswaal-source: <a hash of the graph>
-- roswaal-output: <a hash of what follows>

The first line is the graph's typecheck: --!strict, --!nonstrict, or no line for default. Then come the services the script uses, its requires, its types, its variables, its hoisted functions, its flow, and a module's return. Where the project asks and StyLua is installed, the file is formatted by StyLua.

11.8 Packs and hand-written Luau

  • A pack is a .nodedef.json file, or a .nodedef.luau file that returns a table: read as data, never run.
  • A pack's nodes compile with expr, call or statement templates (§10.5).
  • Graphs can hold hand-written Luau in a Code Block, a step, or a Luau Expression, a value. It is written into the program as it is.

11.9 Moonwave and comment tags

Proposed

Typing a hand-written module's functions for graphs from its Moonwave doc comments, and from Roswaal's own tags where Moonwave has none, in plain -- comments so a Moonwave site still builds (§6.5). Not decided, and not built.