Characters

agents

Finding characters, gadgets, attack targets and ground items.

Everything in the world you can target or interact with is an agent: characters (players, monsters, NPCs, pets), gadgets (nodes, doors, waypoints, objects), attack targets (the hittable parts of some gadgets) and ground items. The agents module finds them and returns Agent handles.

local me = agents.local_player()
if me then
    for _, foe in ipairs(agents.monsters()) do
        if foe:is_alive() and foe:attitude() == agents.ATTITUDE_HOSTILE
            and foe:local_distance() < 900 then
            print(foe:name(), foe:health().percent)
        end
    end
end

Lookups return nil when nothing matches, and lists are empty while there's no map (on the loading screen or at character select).

Lookups

Your character.
Any agent by agent id, whatever kind it is.
A character by agent id.
A gadget by agent id.
An attack target by agent id.
A ground item by agent id.
{name, uuid} of the player you're logged in as.

Players

Every player character nearby, you included.
A player by agent id.
A player by character name.
A player by their uuid (32 hex digits, dashes allowed).

Monsters

Monsters are every character that isn't a player: enemies, NPCs, pets, minions, clones. Their id (agent:monster_id()) is the kind of monster, the same for every one of its kind.

Every monster nearby.
A monster by agent id.
The first monster of a kind, by monster id.
Every monster of a kind.
The first monster with this name.
Every monster with this name.

Gadgets, attack targets and ground items

Every gadget nearby.
The first gadget with this name.
Every gadget with this name.
Every attack target nearby.
Every item lying on the ground nearby.
The first ground item of an item id.
Every ground item of an item id.
The first ground item with this name.
Every ground item with this name.

Selection

Your current target.
Your current target's agent id.
Targets an agent (an Agent or an agent id).
Clears your target.
Whether the target's status (health bar and name above it) is drawn.
Shows or hides the target's status.

Constants

Attitudes, for agent:attitude()
ATTITUDE_FRIENDLYATTITUDE_HOSTILEATTITUDE_NEUTRALATTITUDE_UNATTACKABLE
Dead states, for agent:dead_flags()
DEAD_STATE_ALIVEDEAD_STATE_DOWNEDDEAD_STATE_DEAD
Break bar states, for agent:break_bar().state
BREAK_BAR_AVAILABLEBREAK_BAR_BROKENBREAK_BAR_UNAVAILABLE
Agent types, for agent:agent_type()
TYPE_CHARACTERTYPE_COMBATANTTYPE_GADGETTYPE_GADGET_ATTACK_TARGETTYPE_GROUND_ITEM
Gadget sub-types, for agent:sub_type()
SUBTYPE_NONESUBTYPE_DESTRUCTABLESUBTYPE_POINTSUBTYPE_CRAFTSUBTYPE_DOORSUBTYPE_DOORWAYSUBTYPE_INTERACTSUBTYPE_PLAYER_SPECIFICSUBTYPE_ATK_TARGETSUBTYPE_MAP_PORTALSUBTYPE_WAYPOINTSUBTYPE_RESOURCE_NODESUBTYPE_PROPSUBTYPE_PLAYER_CREATEDSUBTYPE_VISTASUBTYPE_BUILD_SITE