Skip to content
Centurion

Commands and types

If your commands and types are organized into ModuleScripts, they should be registered through the register method.

To be registered, they need to be loaded first. This can be done through the load method, which will require all child ModuleScripts in the container, or a similar method such as addPaths, provided by Flamework.

For commands to be registered, the parent class must be decorated with @Register.

For types, you have two options:

  • Mark the type for registration with markForRegistration. The type will be registered when the register method is called, similar to commands.
  • Export a function from the module (export = (registry: BaseRegistry) => { ... }) and register the type manually using registerType. One caveat here is that you must use the load method for the exported function to be called.
const server = Centurion.server();
// Load command/type modules
server.registry.load(script.Parent.commands);
server.registry.load(ReplicatedStorage.types);
server.start();

Synchronization

Commands registered on the server will be synced to the client. You can filter commands by providing a callback to the syncFilter option on the server.

Types are not synchronized because functions cannot be sent across the network, so you will have to register them on both the server and client. Due to this limitation, it is recommended to store your types in a shared folder you can easily load from both sides.