ObjectQuery

Group
Queries
Methods
11
Fields
None

Getting one

scene:objects()

Methods

MethodReturnsDescription
named(string)ObjectQueryKeep only those whose whole name matches, ignoring case and markup: | separates alternatives and * is any run of characters.
containing(string)ObjectQueryKeep only those whose name contains the text, ignoring case and markup: | separates alternatives.
ids({ number })ObjectQueryKeep only these ids.
hasAction(string | { string })ObjectQueryKeep only those whose definition offers one of actions: an option or a list of them, each matched whole, in any case and with markup igno…
within(number)ObjectQueryKeep only those within a radius of the local player.
withinArea(WorldArea)ObjectQueryKeep only those inside an area.
interactable()ObjectQueryKeep only those the local player can act on right now.
interactableWithin(number, boolean)ObjectQueryKeep only those actable from within a range.
count()numberHow many survived the narrowing. Consumes the query.
nearest()TileObject?The nearest survivor. Consumes the query.
collect(){ TileObject }Every survivor, nearest first. Consumes the query.

Returned by

MethodReturnsDescription
SceneDomain.objectsObjectQueryA query over every scene object: walls, decorations, doors, resources. Every loc in the LOADED SCENE, not a window around the player. Narro…

Method details

named

named: (ObjectQuery, string) -> ObjectQuery

Keep only those whose whole name matches, ignoring case and markup: | separates alternatives and * is any run of characters.

names
The name pattern.

containing

containing: (ObjectQuery, string) -> ObjectQuery

Keep only those whose name contains the text, ignoring case and markup: | separates alternatives.

text
The text to look for.

hasAction

hasAction: (ObjectQuery, string | { string }) -> ObjectQuery

Keep only those whose definition offers one of actions: an option or a list of them, each matched whole, in any case and with markup ignored ("open" keeps an Open door, not an Open-gate one).

scene:objects():named(name):hasAction(action):nearest(), then interact(action) on it when it is not nil, clicks the nearest object of that name whose definition offers action, found in one host crossing. named splits | alternatives, and objects at the same distance keep the scan order.

ids(ids):hasAction(actions):nearest() (named(table.concat(names, "|")) for names), then interact with the first of actions its definition offers (client:getObjectDefinition(o:getId()):getActions()), clicks the nearest object of any listed id offering any listed action.

actions
An option, or a list of options.

interactableWithin

interactableWithin: (ObjectQuery, number, boolean) -> ObjectQuery

Keep only those actable from within a range.

range
How far away to allow, in tiles.
requireLineOfSight
Whether the line of sight must be clear.

count

count: (ObjectQuery) -> number

How many survived the narrowing. Consumes the query.