Custom Ids
Replecs.CustomId
Section titled “Replecs.CustomId”Custom id handler, created with Replecs.create_custom_id.
type CustomId = { identifier: string, handle_callback: (ctx: HandleContext) -> Entity?
handler: (self: CustomId, handler: (ctx: HandleContext) -> Entity?) -> ()}Fields
Section titled “Fields”- identifier: The identifier of the custom id.
- handle_callback: The callback set to handle the custom id.
Methods
Section titled “Methods”- handler(): Sets the handler for the custom id.
- Arguments
- handler: The handler to set.
- Arguments
Replecs.HandleContext
Section titled “Replecs.HandleContext”Context passed when an entity is handled by a custom id. Used to gather information about the entity.
type HandleContext = { entity_id: number,
component: <T>(component: Entity<T>) -> T, target: (relation: jecs.Id, index: number?) -> Entity?, pair_value: <T>(relation: jecs.Id<T>, target: Entity) -> T?, has_pair: (relation: jecs.Id, target: Entity) -> boolean,
entity: (server_entity: number) -> Entity, has: (tag: Entity) -> boolean,}Fields
Section titled “Fields”- entity_id: The server id of the entity being handled.
Functions (Not Methods)
Section titled “Functions (Not Methods)”-
component(): Returns a component value from the entity.
- Arguments
- component: The component to get.
- Arguments
-
target(): Returns the target of a relation, will recursively resolve other custom ids.
- Arguments
- relation: The relation to get the target of.
- index: The index of the target to get. defaults to 0.
- Arguments
-
pair_value(): Returns the value of a pair.
- Arguments
- relation: The relation to get the value of.
- target: The target of the pair, must be a client id.
- Arguments
-
has_pair(): Returns whether the entity has a pair.
- Arguments
- relation: The relation to check.
- target: The target of the pair, must be a client id.
- Arguments
-
has(): Returns whether the entity has a component or tag.
- Arguments
- tag: The tag to check.
- Arguments
-
entity(): Returns an entity from a server entity id, will recursively resolve other custom ids.
- Arguments
- server_entity: The server entity to get.
- Arguments