Sharp Aion2 Lua SDK
API reference

entitiesLua module

Search nearby game entities with bundled Lua helpers.

Import this library with local entities = require("entities"). The records come from game.entities and include id, name, kind, subkind, position, distance, and alive.

entities.nearby(radius, limit)

Parameters: Optional radius defaults to 3000 world units and optional limit to 128. Returns: Entity records in an array, or nil, error.

entities.characters(radius, limit)

Parameters: The same optional radius and limit. Returns: Nearby character records, or nil, error.

entities.living(radius, limit)

Parameters: The same optional radius and limit. Returns: Nearby living character records, or nil, error.

entities.nearest(radius, predicate)

Parameters: Optional radius defaults to 3000. Optional predicate is a function that receives each record and returns a boolean. Returns: The closest matching record, nil when none match, or nil, error on a read failure. It considers at most 512 records.

local entities = require("entities")
local nearest, err = entities.nearest(2500, function(entity)
    return entity.kind == "character" and entity.alive
end)
if nearest then
    log.info(nearest.name)
elseif err then
    log.warn(err)
end