The Roblox demo✎

The project that ships: a module, a server script, and the map that places them.

Pending review

One project, two graphs and a node map. It is examples/demo — the project the Roswaal panel offers to take a copy of, and the one roswaal init leaves you standing in — so what is drawn here is what you would open.

Info

Take a copy rather than opening it in place. Demos under the mark copies it somewhere of your own; the original is shared by everyone who installed Roswaal.

A module, and a function in it

Greeter is a ModuleScript. It declares a function, returns a string from it, and hands the function out through Module Exports — which is the node that decides what require gives back.

AccumulateNumGreetPlayerModule Exportsgreetexport2
The graph this was compiled from, and what it declares.
+ReturnAccumulatedSet VariableAccumulatornumberValueAccumulatorAccumulateNum(number) → numberFunctionAnumber
ConcatenatestringHello, ABGreetPlayer(string) → stringFunctionwhostringReturnmessage
luau
local Accumulator: number = 0

local function AccumulateNum(A: number): number
	Accumulator = A + Accumulator
	return Accumulator
end

local function GreetPlayer(who: string): string
	return "Hello, " .. who
end

return {
	greet = GreetPlayer,
	export2 = AccumulateNum,
}

Info

Each Function has a tab of its own, as in the editor. See Functions.

A script that runs when the place does

Main is a Script, so it runs on the server. It gets a service, requires the module beside it, calls the function out of it, and connects to an event — which between them is most of what any Roblox script does.

SequenceThen 0Then 1{ }Code BlocknewPart.Material = Enum.Material.Neon{ }Code Block-- your Luau hereprint("This is from a custom code block.…local newPart = Instance.new("Part")newPart.Parent = workspace+4 linesConnect EventBodySignalConnectionplayerInstanceplayersJoinedSet VariableplayersJoinednumberValueCall FunctionResultFunctionArgumentRequire ModuleReplicated…InShared.G…PathGreeterAsGet FieldObjectgreetField1+Get PropertyInstanceNamePropertyPrintValueGet EventSignalInstancePlayerAd…EventScript StartGet ServicePlayersPlayersService
The graph this was compiled from, and what it declares.
luau
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Greeter = require(ReplicatedStorage.Shared.Greeter)

-- How many players have joined since the server started.
local playersJoined: number = 0

Players.PlayerAdded:Connect(function(player: Instance)
	local result = Greeter.greet(player.Name)
	print(result)
	playersJoined = playersJoined + 1
end)

-- your Luau here

print("This is from a custom code block.")

local newPart = Instance.new("Part")
newPart.Parent = workspace
newPart.Anchored = true
newPart.Size = Vector3.new(5, 5, 5)

newPart.Position = Vector3.new(10, 5, 10)
newPart.Material = Enum.Material.Neon

Info

Nothing in that file arrived on its own: the require, the Get Service and the Connect are all nodes. See Modules and Services and their methods.

Where it lands in the DataModel

The map says where the generated files go, and compiles to the default.project.json that Rojo reads. This is the demo's own, in the editor that edits it:

  • The treeEvery instance the map describes, with the folder that fills it. Pick one and Instance follows.
  • List or GraphThe tree as rows, or as a graph from left to right with a + on each node to add inside it.
  • DataModel or srcRead the tree from either end: instances with their folders, or folders with where they land.
  • Service, Folder, UndoAdd a service, or a folder in the picked row. Its path comes from the reading rule.
  • The reading ruleWhether every folder is where the rule puts it, and which are not.
  • NameThe instance's name in the DataModel. A folder the rule gave it follows the name.
  • ClassA service, or what Rojo makes. Rojo knows a service by its name.
  • SyncWhether Rojo fills it from its own folder, or it only holds what is mapped under it.
  • PathThe folder on disk that fills it. Choose… picks one from the project.
  • Ignore unknownRojo leaves alone what it did not put there.
  • Ignore pathsGlobs under this path for Rojo to skip.
  • DescribesA DataModel for Roblox, or a filesystem for Lune. It decides the rest.
  • WritesThe project file. Rojo serves default.project.json by default.
  • Place IDs, PortRojo's place settings: where rojo serve may sync, and its port.
  • Project-wide ignoresPassed to Rojo as globIgnorePaths.
  • Project fileWhat the map writes. Picking a row lights its lines.
The demo's map. Select a row and Instance fills with that instance's fields, while the project file scrolls to the lines the row writes.

Rojo projects and node maps is the page about that editor — what each field does — and Compiling for Roblox says what happens when you compile.

Running it

Compile the project, then point Rojo at it and connect from Studio. Roswaal writes the .luau files and the project file; everything after that is Rojo's, and Roswaal never talks to Studio itself.

sh
roswaal compile   # writes src/ and default.project.json
rojo serve        # then connect from Studio

Info

The demo also ships two node packs in .roswaal/nodes, unused by these graphs, to open in Node Design. See Creating custom nodes.

Not reviewed yet