Minimap API
Minimap API
Access minimap functionality including visibility checks, coordinate conversions, and finding visible tiles.
Functions
map_component
minimap:map_component() -> Component | nil
Returns the minimap component for both fixed and resizable modes.
Returns:
Component | nil- The minimap component, or nil if not visible
Example:
local minimap_comp = minimap:map_component()
if minimap_comp then
print("Minimap center:", minimap_comp:center_x(), minimap_comp:center_y())
end
zoom
minimap:zoom() -> number | nil
Returns the current minimap zoom level.
Returns:
number | nil- The zoom level (2 = zoomed out, 4 = default, 8 = zoomed in), or nil if unavailable
Example:
local zoom = minimap:zoom()
print("Current zoom:", zoom) -- e.g., 4 (default)
tile_visible
minimap:tile_visible(tile: Tile) -> boolean
Checks if a tile is currently visible on the minimap.
Parameters:
tile(Tile) - The tile to check
Returns:
boolean- True if the tile is visible on the minimap
Example:
local tile = Tile.new(3200, 3200, 0)
if minimap:tile_visible(tile) then
print("Tile is visible on minimap")
end
tile_to_map
minimap:tile_to_map(tile: Tile) -> Point | nil
Converts a world tile to minimap screen coordinates.
Parameters:
tile(Tile) - The world tile to convert
Returns:
Point | nil- The screen coordinates on the minimap, or nil if not visible
Example:
local player = players:local_player()
local tile = player:tile()
local point = minimap:tile_to_map(tile)
if point then
print("Player on minimap at:", point.x, point.y)
mouse:move(point.x, point.y)
end
closest_tile_on_map
minimap:closest_tile_on_map(locatable: Tile | Player | Npc | GameObject | GroundItem) -> Tile | nil
Finds the closest tile to the local player that is currently visible on the minimap. Uses Bresenham's line algorithm to walk from the target towards the player.
Parameters:
locatable- The target to walk towards (accepts Tile, Player, Npc, GameObject, or GroundItem)
Returns:
Tile | nil- The closest visible tile on the minimap, or nil if none found (within 500ms timeout)
Example:
-- Find closest visible tile to a target
local target_tile = Tile.new(3200, 3200, 0)
local visible = minimap:closest_tile_on_map(target_tile)
if visible then
movement:walk_to(visible)
end
-- Works with any Locatable type
local npc = npcs:find_first({name = "Banker"})
if npc then
local closest = minimap:closest_tile_on_map(npc)
if closest then
movement:walk_to(closest)
end
end
Related APIs
- Movement API - Player movement and pathfinding
- Camera API - Camera controls
- Players API - Access player data
- NPCs API - Query NPCs
- GameObjects API - Query game objects