Entity
Names and lookup. Entities are plain numeric ids; a name is optional and need not be unique.
Namespace: caffeine.entity · Dryad prefix: caffeine_entity_
name#
Lua: caffeine.entity.name · Dryad: caffeine_entity_name
name(entity) -> string
Reads the editor name of an entity.
| Parameters | Type | Description |
|---|---|---|
entity | number | The entity id. |
Returns: string. The name, or an empty string when unnamed or dead.
Example
print(caffeine.entity.name(eid))
setName#
Lua: caffeine.entity.setName · Dryad: caffeine_entity_set_name
setName(entity, name) -> boolean
Names an entity so it can be found later.
| Parameters | Type | Description |
|---|---|---|
entity | number | The entity id. |
name | string | New name, at most 63 characters. |
Returns: boolean. false when the entity is not alive.
Example
caffeine.entity.setName(eid, "Boss")
find#
Lua: caffeine.entity.find · Dryad: caffeine_entity_find
find(name) -> number
Finds an entity by name.
| Parameters | Type | Description |
|---|---|---|
name | string | Exact name to look for. |
Returns: number. The lowest matching entity id, or 0 when none.
Example
local boss = caffeine.entity.find("Boss")
findAll#
Lua: caffeine.entity.findAll · Dryad: caffeine_entity_find_all
findAll(name) -> table
Finds every entity with a name.
| Parameters | Type | Description |
|---|---|---|
name | string | Exact name to look for. |
Returns: table. Array of matching entity ids, ascending (empty when none).
Example
for _, id in ipairs(caffeine.entity.findAll("Coin")) do caffeine.world.destroy(id) end
isAlive#
Lua: caffeine.entity.isAlive
isAlive(entity) -> boolean
Tells whether an id still refers to a live entity. Dryad: use caffeine_world_is_alive.
| Parameters | Type | Description |
|---|---|---|
entity | number | The entity id. |
Returns: boolean. true when the entity exists.
Example
if caffeine.entity.isAlive(target) then end