Rogen

Multi-Place Games

Set up Rogen for a game with more than one place

Updated

Each place has a config of its own, and shared code is a plain folder that every place lists in its sourcePaths. Where a place and the shared folder have a file at the same path, the place's file wins.

Start a Multi-Place Game

In an empty folder, rogen init --places writes a first place, game, with its code in src/game and shared code in src/common:

game.rogen.json
{
	"name": "game",
	"sourcePaths": ["src/common", "src/game"],
	"routes": {
		"Server": "ServerScriptService",
		"Client": "StarterPlayer/StarterPlayerScripts",
		"Shared": "ReplicatedStorage/Shared",
		"*": "ReplicatedStorage/Shared"
	},
	"tree": { "$className": "DataModel" }
}

There is no default.rogen.json, so name the place in each command. To serve two places at once, give the second its own --port:

rogen serve game
rogen build game -o game.rbxl

Add a Place

Copy the first config, then set its "name" to "lobby" and point sourcePaths at src/lobby. If you kept the sample, copy its place folder too and point the tree's $paths at the copy:

cp game.rogen.json lobby.rogen.json
mkdir src/lobby
cp -r place/game place/lobby

Places in roblox-ts

With --language roblox-ts, each place also gets a tsconfig that compiles the shared code and the place's own code into the place's compiledPath:

tsconfig.game.json
{
	"extends": "./tsconfig.json",
	"compilerOptions": {
		"rootDir": "src",
		"rootDirs": ["src/common", "src/game"],
		"outDir": "out/game",
		"composite": true
	},
	"include": ["src/common", "src/game"],
	"rbxts": { "rojo": "game.project.json" }
}

Keep rootDir at src, the folder that holds both source paths, so the compiled files keep the folders they have in src; TypeScript 6 and later also refuse to compile without it. The root tsconfig.json holds the options every place shares and lists each place under references, so the editor checks a file against its own place.

To add a place, after copying the config as above:

  1. Set "compiledPath" in lobby.rogen.json to out/lobby.
  2. Copy tsconfig.game.json to tsconfig.lobby.json and change each game in it to lobby.
  3. Add { "path": "./tsconfig.lobby.json" } to the references in tsconfig.json.
  4. Add && rbxtsc -p tsconfig.lobby.json to the build script in package.json. rbxtsc -w runs until you stop it, so watch the new place from a terminal of its own with npx rbxtsc -w -p tsconfig.lobby.json.

On this page