Version: 3.0.4

Using Compile Time Remote IDs

TypeScript Only

This functionality is only available to roblox-ts users. This is not possible in regular Luau.

This method uses a transformer called rbxts-transform-guid and is quite experimental.

Installation#

npm i -D rbxts-transform-guid

Once installed, you will need to configure it in your tsconfig.json under plugins:

{
"compilerOptions": {
// ..
"plugins": [
// ...
{
"transform": "rbxts-transform-guid",
"EXPERIMENTAL_JSDocConstEnumUUID": true
}
]
}
}

Then if you want to create remote ids, you create a const enum like such:

/**
* @uuid
*/
export const enum RemoteId {
GetPlayerInventory = "GetPlayerInventory"
}

uuid is important here, it's what tells our transformer to convert our enum values to guids at compile time.

Then in your definition file you can use it as such:

src/shared/remotes.ts
import Net from "@rbxts/net";
/**
* @uuid
*/
export const enum RemoteId {
GetPlayerInventory = "GetPlayerInventory"
}
const Remotes = Net.CreateDefinitions({
[RemoteId.GetPlayerInventory]: Net.Definitions.ServerAsyncFunction<() => InventorySlot[]>(),
});
export default Remotes;

Then you can use it as such:

src/server/example.server.ts
import Remotes, { RemoteId } from "src/shared/remotes";
const getPlayerInventory = Remotes.Server.Get(RemoteId.GetPlayerInventory);
// ...