Replecs
Replecs
Section titled “Replecs”Replecs.create
Section titled “Replecs.create”Creates a new ReplecsLib. This contains both the server and client replicators
in one object and provides methods to interact with both of them at the same time.
function Replecs.create(world: jecs.World?): ReplecsLibArguments
Section titled “Arguments”- world: The world to use for the replicators. Can also be provided when initing the replicator.
Replecs.create_server
Section titled “Replecs.create_server”Creates a new server replicator.
function Replecs.create_server(world: jecs.World?): Replecs.ServerArguments
Section titled “Arguments”- world: The world to use for the replicators. Can also be provided when initing the replicator.
Replecs.create_client
Section titled “Replecs.create_client”Creates a new client replicator.
function Replecs.create_client(world: jecs.World?): Replecs.ClientArguments
Section titled “Arguments”- world: The world to use for the replicators. Can also be provided when initing the replicator.
Replecs.create_custom_id
Section titled “Replecs.create_custom_id”Creates a new handler for parsing custom entity ids.
function Replecs.create_custom_id( identifier: string, handler: ((ctx: HandleContext) -> Entity?)?): CustomIdArguments
Section titled “Arguments”- identifier: A string that will be used to identify the custom id when gets through the network. Must be the same in both the server and client.
- handler: A function handler that will pass use the
HandleContextto create or return the entity. Optionally, the handler can be ommited and set later withcustomid:handler(handler)
Replecs.ReplecsLib
Section titled “Replecs.ReplecsLib”Container for both the server and client replicators.
type ReplecsLib = { server: Replecs.Server?, client: Replecs.Client?,
after_replication: (self: ReplecsLib, callback: () -> ()) -> (), register_custom_id: (self: ReplecsLib, custom_id: CustomId) -> (),}Fields
Section titled “Fields”- server: The server replicator, nil in the client.
- client: The client replicator, nil in the server.
Methods
Section titled “Methods”- after_replication(): Registers a callback to be called after the replication has finished.
If not replication is in progress, the callback will be called immediately. If this is called in the server, the callback will always be called immediately.- Arguments
- callback: The callback to be called.
- Arguments
- register_custom_id(): Calls
register_custom_idon the server and/or client replicators.- Arguments
- custom_id: The custom id to register.
- Arguments