Skip to content
M2O Scripting APIScripting reference
Global objectClient APIGenerated

WorldMap

const WorldMap: object

Defined in: client/api.d.ts:1375

Client controls for the in-game world map and its GPS waypoint.

calculateRoute(startX, startY, startZ, endX, endY, endZ): Vector3[] | null

Computes the road route between two world positions with the same road graph the minimap GPS uses, without touching the player’s own waypoint. Both ends snap to the nearest road, so routes follow the road network and never cut across terrain or through interiors. The route spans at most 128 road segments.

number

World-space X coordinate of the route start.

number

World-space Y coordinate of the route start.

number

World-space Z coordinate of the route start.

number

World-space X coordinate of the route destination.

number

World-space Y coordinate of the route destination.

number

World-space Z coordinate of the route destination.

Vector3[] | null

The route as world-space points, an empty array when no route connects the two positions, or null while the road graph is unavailable (in the menu, or before the city has streamed in).

const route = WorldMap.calculateRoute(px, py, pz, tx, ty, tz);
if (route && route.length) {
// route[0] is on the road nearest the start, route[route.length - 1] nearest the destination.
}

clearWaypoint(): void

Removes the active GPS waypoint and its route.

void

close(): boolean

Closes the in-game world map.

boolean

True when the close request succeeded.

isOpen(): boolean

Checks whether the in-game world map is currently open.

boolean

True while the map screen is active.

open(): boolean

Opens the in-game world map.

boolean

True when the map was opened successfully.

setWaypoint(x, y): void

Sets or replaces the local GPS waypoint and computes its route. Routing uses the map’s two-dimensional road graph, so there is no Z coordinate. Placing one this way does not raise a manual placement to the server.

number

World-space X coordinate of the destination.

number

World-space Y coordinate of the destination.

void