Entity:give
Gives an Entity a Component.
entity = entity:give( name, ... )
Section titled “entity = entity:give( name, ... )”Gives an Entity a Component.
If the Component already exists, it’s overridden by this new Component.
entity = entity:give( name, ... )Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
name |
string | Name of the ComponentClass |
... |
any | Additional arguments to pass to the Component’s populate function |
Returns
Section titled “Returns”| Name | Type | Description |
|---|---|---|
entity |
Entity |
entity = entity:give( component )
Section titled “entity = entity:give( component )”entity = entity:give( component )Pass an existing Component instance (already populated, not attached to an entity). Skips name and populate arguments.
Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
component |
Component |
Returns
Section titled “Returns”| Name | Type | Description |
|---|---|---|
entity |
Entity |
Concord.Component("position", function (component, x, y) component.x = x or 0 component.y = y or 0end)
entity:give("position", 10, 20) -- 10 and 20 are passed to populate after `component`