named: (NPCQuery, string) -> NPCQuery
Keep only those whose whole name matches, ignoring case and markup: | separates alternatives and * is any run of characters, so "Goblin" is not a Hobgoblin and "Guard|*goblin" is a guard, a goblin and a Hobgoblin. Alternative to walking the NPCs with an if on each getName() to find the ones of a name each tick: the host narrows the scene by name, one crossing for the set.
names- The name pattern.
containing: (NPCQuery, string) -> NPCQuery
Keep only those whose name contains the text, ignoring case and markup: | separates alternatives, so "goblin" is a Goblin and a Hobgoblin.
text- The text to look for.
ids: (NPCQuery, { number }) -> NPCQuery
Keep only these ids.
ids- The ids to keep.
within: (NPCQuery, number) -> NPCQuery
Keep only those within a radius of the local player.
radius- Chebyshev distance in tiles.
withinArea: (NPCQuery, WorldArea) -> NPCQuery
Keep only those inside an area.
area- The area to stay inside.
withinPath: (NPCQuery, number) -> NPCQuery
Keep only those a walk of at most steps reaches from the local player.
steps- The longest path to allow.
combatLevelAbove: (NPCQuery, number) -> NPCQuery
Keep only those above a combat level.
min- The level to beat.
combatLevelBelow: (NPCQuery, number) -> NPCQuery
Keep only those below a combat level.
max- The level to stay under.
combatLevelBetween: (NPCQuery, number, number) -> NPCQuery
Keep only those between two combat levels, both ends included.
low- The lowest level to keep.
high- The highest level to keep.
reachable: (NPCQuery) -> NPCQuery
Keep only those the local player can walk to.
interactable: (NPCQuery) -> NPCQuery
Keep only those the local player can act on right now: a tile beside the NPC's footprint, on any side, can be walked to.
- Example
-- The nearest goblin the player can act on now: a tile beside it, on any
-- side, can be walked to. Not one behind a fence.
local goblin = scene:npcs():named("Goblin"):interactable():nearest()
if goblin then
goblin:interact("Attack")
end
interactableWithin: (NPCQuery, number, boolean) -> NPCQuery
Keep only those actable from within a range of their footprint.
range- How far away to allow, in tiles.
requireLineOfSight- Whether the line of sight must be clear.
exclude: (NPCQuery, NPC | { NPC }) -> NPCQuery
Drop an NPC -- the one already being fought, say -- or several. Takes the handles, not ids: an id is not unique in a scene full of the same monster.
npcs- The NPC or NPCs to leave out.
hasLineOfSight: (NPCQuery) -> NPCQuery
Keep only those with a clear line of sight to the local player.
count: (NPCQuery) -> number
How many survived the narrowing. Consumes the query.
nearest: (NPCQuery) -> NPC?
The nearest survivor. Consumes the query.
- Returns
nil when none survived.
collect: (NPCQuery) -> { NPC }
Every survivor, nearest first. Consumes the query.