Skip to content
ConcordConcordConcord

Entity:give

Gives an Entity a Component.

← Entity

Gives an Entity a Component.

If the Component already exists, it’s overridden by this new Component.

entity = entity:give( name, ... )
Name Type Description
name string Name of the ComponentClass
... any Additional arguments to pass to the Component’s populate function
Name Type Description
entity Entity

entity = entity:give( component )

Pass an existing Component instance (already populated, not attached to an entity). Skips name and populate arguments.

Name Type Description
component Component
Name Type Description
entity Entity
Concord.Component("position", function (component, x, y)
component.x = x or 0
component.y = y or 0
end)
entity:give("position", 10, 20) -- 10 and 20 are passed to populate after `component`