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:
{
"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.rbxlAdd 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/lobbyPlaces 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:
{
"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:
- Set
"compiledPath"inlobby.rogen.jsontoout/lobby. - Copy
tsconfig.game.jsontotsconfig.lobby.jsonand change eachgamein it tolobby. - Add
{ "path": "./tsconfig.lobby.json" }to thereferencesintsconfig.json. - Add
&& rbxtsc -p tsconfig.lobby.jsonto thebuildscript inpackage.json.rbxtsc -wruns until you stop it, so watch the new place from a terminal of its own withnpx rbxtsc -w -p tsconfig.lobby.json.