Returns all components of a specific class or inheriting from it.
Usage
ecs:components(class)
Arguments
Name
Type
Description
class
string or component class
The component class to list instances of, as a string or as a reference.
Returns
Name
Type
Description
components
table
A table where each key is a component of the specified class or inherits from it.
Examples
localStat=Class("Stat",crystal.Component);localHealth=Class("Health",Stat);localMana=Class("Mana",Stat);localecs=crystal.ECS:new();localentity=ecs:spawn(crystal.Entity);entity:add_component("Health");entity:add_component("Mana");forcomponentinpairs(ecs:components("Stat"))do-- Prints "Instance of class: Health" and "Instance of class: Mana"print(component);end