TileObject

Methods
18
Fields
None

Getting one

scene:objects():nearest()

Methods

MethodReturnsDescription
getHash()numberThe scene tag: worldView >> 52 & 4095, id >> 20 & 0xffffffff, wall >> 19 & 1, type >> 16 & 7, plane >> 14 & 3, scene y `>> 7 & 12…
getHashString()stringThe hash as its decimal string, exact for every world view. Use it where you key a map by the hash: the number getHash() answers passes 2…
getX()numberThe local x of the object's centre.
getY()numberThe local y of the object's centre.
getZ()numberThe height the object was placed at.
getPlane()numberThe plane of the tile the object is on.
getId()numberThe loc id (ObjectID), as its tag carries it.
getWorldView()WorldViewThe world view the object is in.
getWorldLocation()WorldPointThe world tile of the object, against its world view's current base: for a game object the middle of its footprint rounded to the south-wes…
getLocalLocation()LocalPointThe local point of the object's centre.
getCanvasLocation()Point?(TileObject) -> Point?: Where its local centre projects onto the canvas, at its plane's ground height (`Perspective.localToCanvas(client,…
getCanvasLocation(number)Point?
getCanvasTilePoly()Polygon?The outline of the tiles it stands on, on the canvas (a game object's whole footprint, sizeX by sizeY; one tile for the rest), as `Pers…
getCanvasTextLocation(Graphics2D, string?, number)Point?The canvas point to draw text at, centred on the object's local location zOffset up (Perspective.getCanvasTextLocation: the anchor on…
getMinimapLocation()Point?Where the object's local centre is on the minimap (Perspective.localToMinimap(client, getLocalLocation())), or nil past the minimap's r…
getCanvasTextLocationForWidth(number, number)Point?The point getCanvasTextLocation(graphics, text, zOffset) gives, for text textWidth pixels wide, without a graphics (outside a render, o…
getClickbox()Shape?The shape a click on it lands in, on the canvas: its model's clickbox (Perspective.getClickbox over the loc's model; a wall's two models…
isPresent()booleanWhether the object is still in its scene: Bento's, for code that keeps handles (a removed object's handle answers its last values).
interact(string)booleanAct on the object through the virtual mouse: option is one of its menu actions ("Open", "Chop down"; "" for the first). The scheduler r…

Returned by

MethodReturnsDescription
ObjectQuery.collect{ TileObject }Every survivor, nearest first. Consumes the query.
ObjectQuery.nearestTileObject?The nearest survivor. Consumes the query.

Method details

getHash

getHash: (TileObject) -> number

The scene tag: worldView >> 52 & 4095, id >> 20 & 0xffffffff, wall >> 19 & 1, type >> 16 & 7, plane >> 14 & 3, scene y >> 7 & 127, scene x & 127. The hash of a loc in world view 2 or above is past 2^53, which a Luau number does not hold exactly: then this raises, and getHashString() is the exact form.

getHashString

getHashString: (TileObject) -> string

The hash as its decimal string, exact for every world view. Use it where you key a map by the hash: the number getHash() answers passes 2^53 for a loc in world view 2 or above (a boat's), and getHash() raises there.

getId

getId: (TileObject) -> number

The loc id (ObjectID), as its tag carries it.

getWorldLocation

getWorldLocation: (TileObject) -> WorldPoint

The world tile of the object, against its world view's current base: for a game object the middle of its footprint rounded to the south-west (fromScene(minX + (maxX - minX) / 2, ...)), so a 1x1 is its tile, a 2x2 its south-west tile and a 3x3 its middle one; for the other kinds the tile of its local centre. A 2x2's getLocalLocation() is a tile north-east of it. On an NPC-owned boat (a charter ship, a Barracuda Trials rum boat), the sea tile under that tile instead, the tile its scene:objects() row measures by.

getCanvasLocation

getCanvasLocation: ((TileObject) -> Point?) & ((TileObject, number) -> Point?)

(TileObject) -> Point?: Where its local centre projects onto the canvas, at its plane's ground height (Perspective.localToCanvas(client, getLocalLocation(), getPlane())), or nil when it does not project (another world view, off the scene, no camera).

(TileObject, number) -> Point?: As getCanvasLocation(), zOffset above the ground.

getCanvasTilePoly

getCanvasTilePoly: (TileObject) -> Polygon?

The outline of the tiles it stands on, on the canvas (a game object's whole footprint, sizeX by sizeY; one tile for the rest), as Perspective.getCanvasTileAreaPoly gives it; nil when it does not project.

getCanvasTextLocation

getCanvasTextLocation: (TileObject, Graphics2D, string?, number) -> Point?

The canvas point to draw text at, centred on the object's local location zOffset up (Perspective.getCanvasTextLocation: the anchor on its world view's plane, x less half the text's width in the graphics' current font, getStringBounds); nil for nil text or when the point does not project. The text is measured only when it does.

getMinimapLocation

getMinimapLocation: (TileObject) -> Point?

Where the object's local centre is on the minimap (Perspective.localToMinimap(client, getLocalLocation())), or nil past the minimap's radius, with the minimap hidden, or with nothing to read.

getCanvasTextLocationForWidth

getCanvasTextLocationForWidth: (TileObject, number, number) -> Point?

The point getCanvasTextLocation(graphics, text, zOffset) gives, for text textWidth pixels wide, without a graphics (outside a render, or with a width measured once). getCanvasTextLocation measures the text itself; the point is Perspective.getCanvasTextLocation's (the anchor on its world view's plane, zOffset up, x less half the width).

getClickbox

getClickbox: (TileObject) -> Shape?

The shape a click on it lands in, on the canvas: its model's clickbox (Perspective.getClickbox over the loc's model; a wall's two models as one shape, a decoration's at its offsets; an animated loc's model as it poses it for the current cycle), nil when it does not project, its model is not readable (an animated loc, or any loc in HD, where the table has that model's read off) or it is gone.

isPresent

isPresent: (TileObject) -> boolean

Whether the object is still in its scene: Bento's, for code that keeps handles (a removed object's handle answers its last values).

interact

interact: (TileObject, string) -> boolean

Act on the object through the virtual mouse: option is one of its menu actions ("Open", "Chop down"; "" for the first). The scheduler resolves the loc by id and origin tile in its world view, moves the virtual mouse and clicks. false when the object is gone, or it is outside the top level, the boat the player stands in and the NPC-owned boats in the scene (on another player's boat).