old Entity Collection API - latibro/Automation-Mod GitHub Wiki
API to access a collection of entities (Entity API).
This will give a collection of entities. The collection may be dynamic, so the entities in the collection may change over time.
An example of a dynamic collection would be the "loaded entities" (from World API or Server API), where the list will change while chunks are loaded and unloaded, and entities are killed/spawned.
Example
local world = interfaceBox.getAPI("world")
local loadedEntities = world.getAllLoadedEntity()
local entities = loadedEntities.getAll()
print("Total number of loaded entities: " .. #entities)
function getAll() : array<entity : userdata<EntityAPI>>
Returnes the entities as an array (lua table)
Returns
- array (table) of EntityAPI (userdata)
Usage
local entities = entityCollection.getAll()
function getByUUID(uuid: string) : userdata<EntityAPI>
Returns the entity with the gives UUID.
Parameters
- UUID (string) of the entity
Returns
- EntityAPI (userdata) with the given UUID (or nil on errors)
Errors
- Entity not in collection
Usage
local entity = entityCollection.getByUUID("f2654a86-f752-4109-9279-ce67b46c3a4e")