LocalTile Type

LocalTile

A LocalTile represents a position in the currently loaded scene using raw local center coordinates.

Unlike Tile, which uses world coordinates, LocalTile is relative to the scene base and is best used when working with local movement, scene positions, and objects that expose local coordinates.

Properties

PropertyTypeDescription
xnumberRaw local center x coordinate
ynumberRaw local center y coordinate
floornumberThe floor/plane level

Constructors

LocalTile.new

LocalTile.new(x: number, y: number, floor?: number) -> LocalTile
LocalTile.new(tbl: {x: number, y: number, floor?: number}) -> LocalTile

Creates a LocalTile from raw local center coordinates.

Example:

local tile = LocalTile.new(6400, 6464, 0)
local same = LocalTile.new({x = 6400, y = 6464, floor = 0})

LocalTile.from_scene_coords

LocalTile.from_scene_coords(x: number, y: number, floor?: number) -> LocalTile

Creates a LocalTile from scene tile coordinates in the 0..103 range.

Example:

local scene_tile = LocalTile.from_scene_coords(50, 50, 0)

LocalTile.from_local_coords

LocalTile.from_local_coords(x: number, y: number, floor?: number) -> LocalTile

Creates a LocalTile from raw local center coordinates. This is equivalent to LocalTile.new(...), but is explicit about the coordinate space.

Example:

local player = players:local_player()
local tile = LocalTile.from_local_coords(player:local_x(), player:local_y(), player:floor())

LocalTile.from_tile

LocalTile.from_tile(tile: Tile) -> LocalTile

Converts a world Tile into a LocalTile using the current scene base.

Example:

local world_tile = Tile.new(3200, 3200, 0)
local local_tile = LocalTile.from_tile(world_tile)

Coordinate Helpers

local_x / local_y

tile:local_x() -> number
tile:local_y() -> number

Returns the raw local center coordinates.

scene_x / scene_y

tile:scene_x() -> number
tile:scene_y() -> number

Returns the scene tile coordinates in the 0..103 range.

world_x / world_y

tile:world_x() -> number
tile:world_y() -> number

Returns the corresponding world coordinates.

to_tile

tile:to_tile() -> Tile

Converts this local tile into a world Tile.

Example:

local local_tile = LocalTile.from_scene_coords(50, 50, 0)
local world_tile = local_tile:to_tile()

Distance and Comparison

distance

tile:distance() -> number

Distance from this local tile to the local player.

distance_to

tile:distance_to(other: LocalTile) -> number

Distance to another LocalTile.

manhattan_distance_to

tile:manhattan_distance_to(other: LocalTile) -> number

Manhattan distance to another LocalTile.

is_within_distance

tile:is_within_distance(other: LocalTile, distance: number) -> boolean

Checks whether another local tile is within a given distance.

is_same_floor

tile:is_same_floor(other: LocalTile) -> boolean

Checks whether two local tiles are on the same floor.

equals

tile:equals(other: LocalTile | Tile | {x: number, y: number, floor?: number}) -> boolean

Checks coordinate equality.


Utility Methods

derive

tile:derive(dx: number, dy: number) -> LocalTile

Creates a new local tile offset from this one.

reachable

tile:reachable() -> boolean

Checks whether this tile is reachable.

tbl

tile:tbl() -> {x: number, y: number, floor: number}

Converts the tile into a plain Lua table.

base_point / next_point

tile:base_point() -> number, number
tile:next_point() -> number, number

Returns projected screen coordinates for this tile.


Interaction Methods

click / shift_click / interact

tile:click() -> boolean
tile:shift_click() -> boolean
tile:interact(filters?) -> boolean

Interact with the tile.

is_visible / move_mouse_to / track

tile:is_visible() -> boolean
tile:move_mouse_to() -> boolean
tile:track()

Helpers for visibility checks and mouse movement/tracking.

Example

local player = players:local_player()
if not player then
    return
end

local here = player:local_tile()
local next_tile = here:derive(128, 0)

logger:info(string.format(
    "local=(%d,%d) scene=(%d,%d) world=(%d,%d)",
    here:local_x(),
    here:local_y(),
    here:scene_x(),
    here:scene_y(),
    here:world_x(),
    here:world_y()
))

if next_tile:reachable() then
    next_tile:move_mouse_to()
end