Entity:ensure
Ensures an Entity has a Component.
entity = entity:ensure( name, ... )
Section titled “entity = entity:ensure( name, ... )”Ensures an Entity has a Component.
If the Component already exists, no action is taken.
entity = entity:ensure( 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:ensure( component )
Section titled “entity = entity:ensure( component )”entity = entity:ensure( 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 |