Appearance
ECR
Functions
registry()
Creates a new registry.
Type
luafunction ecr.registry(): Registry
component()
Creates a new component type.
Type
luafunction ecr.component(): unknown function ecr.component<T>(constructor: () -> T): T
Details
Returns a unique id representing a new component type.
Can be given a constructor which can be invoked when
registry:add()
orregistry:patch()
is used.Example
No constructor.
lualocal Position = ecr.component() :: Vector3 local Health = ecr.component() :: number
With constructor.
lualocal Position = ecr.component(Vector3.new) local Health = ecr.component(function() return { Current = 100, Max = 100 } end)
tag()
Creates a new tag component type.
Type
luafunction ecr.tag(): nil
Details
Returns a unique id representing a new component type.
Tag components are a special type of component that have no value.
is_tag()
Checks if a component type is a tag.
Type
luafunction ecr.is_tag<T>(ctype: T): boolean
queue()
Creates a new queue.
Type
luafunction ecr.queue(): Queue<...unknown> function ecr.queue<T...>(signal: ISignal<T...>) -> Queue<T...> type ISignal<T...> = { connect: (ISignal, (T...) -> ()) -> () } | { Connect: (ISignal, (T...) -> ()) -> () }
Details
Can accept any signal object that matches the interface to automatically connect a callback where any arguments it is called with are added to the queue.
name()
Associates names with components for debugging.
Type
luafunction ecr.name<T>(names: T & Map<string, unknown>) -> T
Details
Allows for errors raised to display the component name instead of its argument position.
buffer_to_array()
Converts a buffer of entities into an array of entities.
Type
luafunction ecr.buffer_to_array(buf: buffer, size: number, arr: Array<entity>?) -> Array<entity>
Details
Copies the first
size
ids from the buffer to a target array.If no target array is given, one will be created.
array_to_buffer()
Converts an array of entities into a buffer of entities.
Type
luafunction ecr.buffer_to_array(arr: Array<entity>, size: number, buf: buffer?) -> buffer
Details
Copies the first
size
ids from an array to a target buffer.If no target buffer is given, one will be created.
Constants
entity
Special component type that represents entities in a registry.
Type
luaecr.entity: entity
context
The context entity id.
Type
luaecr.context: entity
null
The null entity id.
Type
luaecr.null: entity
Details
Attempting to use this entity with a registry will error.
The following expression will always return
false
:luaregistry:contains(ecr.null)
id_size
The size of the entity id in bytes.
Type
luaecr.id_size: number