Skip to content
Maks edited this page Feb 16, 2019 · 5 revisions

Actor

Actor:get(componentTypeName)

Gets a component by name, returns nil if not found.

Actor:add(componentTypeName)

Adds a component of type with the given name and returns it.

Actor:add(componentTypeName, componentDefinition)

Adds a component of type with the given name from a given definition and returns it. Uses a given component definition to create the component. The type of it depends on the component type, but most use a table.

Actor:remove(componentTypeName)

If this actor has a component with the given type name, removes the component from the actor.

Actor:destroy()

Marks the actor for destruction. Note that this actor will only destroyed at the end of this update, and this reference to it will remain valid until then.

Actor:destroyImmediate()

Immediately destroys the actor and invalidates this object. Must not be called in callback functions. Just use Actor:destroy instead.

Properties Type Notes
name string
isValid bool true if this actor is valid (non-destroyed). Read-only
isDestroyed bool true if this actor is not valid or has been marked for destruction with Actor:destroy(). Read-only