AzerothGPS
AzerothGPS › More

Your Route in Other Addons

Second-screen maps and other addons that show your route, how to turn it off, and the route API for developers.

Since 1.4.3, other addons can read the route you're following in AzerothGPS. A second-screen map, such as Twinmap's TwinmapForever addon, can show your trip on another screen: where you're headed, each walk, flight, boat and portal on the way, and the time left.

Many of these addons were made to read Shortest Path Forever's route. When Shortest Path Forever isn't loaded, AzerothGPS answers in its place, so those addons show your AzerothGPS route with no changes. When Shortest Path Forever is loaded, AzerothGPS leaves it alone.

Other addons can read your route. Since 1.4.4, a companion addon can also choose how far you can stray from it before AzerothGPS reroutes, or hold off rerouting for a while, for example while you fight a mob or pick a herb off the road. Every hold runs out on its own. Picking a new destination always reroutes at once. Nothing they do changes your stops or moves your character.

To stop sharing, open Options > Routing and, under Waypoints and sharing, untick Share my route with addons made for Shortest Path. It's on by default. Addons that read AzerothGPS by its own name can still see the route.

For addon developers#

The route is on the public AzerothGPS table (AzerothGPS.API is the same table) from version 24. Check AzerothGPS.version >= 24 first, and add ## OptionalDeps: AzerothGPS to your toc so it loads before you. The calls are shaped like Shortest Path Forever's route API (its version 2, minor 4), so an addon written for that one can read AzerothGPS by changing one name. Every answer is a new table, and nothing you do with it changes the route.

The calls#

  • Journey(): the route, or nil and a reason: "none" (no route), "loading" (the first route is still being worked out) or "unreachable" (no way found yet).
  • Route(): the same as Journey().
  • Guidance(): the walk ahead: leg (always 1), waypoints (the route's line from the player, at most 200 places), point (the next one ahead) and index (its place in waypoints). nil and a reason when there's none.
  • JourneyState(): always a table: busy, pending, settling, blocked ("combat", "corpse" or nil), index and legs, each { mode, measured }.
  • Active(): true while there's a route (stops set and routing not paused).
  • OnRouteChanged(owner, fn): calls fn(what) when the route changes. what is "replanned" (worked out again, or its stops changed), "settled" (worked out in full) or "cleared". The route is checked every half second while anyone listens. Pass fn = nil to stop.
  • Subscribe(callback): as Shortest Path's: callback(changes), with any of started, changed (the goal changed), ended, stop, leg, replan and active set to true. It returns a function that stops it.

What Journey() returns#

  • goal: the trip's last stop, a place with title, its name.
  • legs: in order from where the player is. Legs already behind the player are left out. Each leg has:
    • mode: "walk", "flight", "boat", "zeppelin", "tram", "lift", "portal" or "teleport";
    • kind: more detail, such as "hearth" for the hearthstone, "party portal" for a party mage's portal or "teleporter"; otherwise the same as mode;
    • text: the step in the player's language, with no color codes;
    • from and to: places;
    • seconds: whole seconds, a ride's wait included;
    • stop: which of stops the leg leads to, and yards for a walk.
  • secondsLeft: the legs' seconds added up.
  • settling: true while the route is still being worked out. The legs can change once it settles.
  • stops: every stop of the trip in order, as places with title.
  • provider is "AzerothGPS", index is always 1 and guided is true.

A place is { map, x, y, z, level, worldX, worldY }. map is the uiMapID of the zone or city it's in, and x (east) and y (south) run from 0 to 1 on that map. z is the height in yards, and it's there only where AzerothGPS knows the real one. level, worldX and worldY are AzerothGPS's own world coordinates. Inside a dungeon, where no zone map holds the place, map, x and y are nil.

An example#

local function ShowRoute()
  local journey, why = AzerothGPS.API.Journey()
  if not journey then return end -- why: "none", "loading" or "unreachable"
  print(journey.goal.title, journey.secondsLeft .. " seconds left")
  for i, leg in ipairs(journey.legs) do
    print(i, leg.mode, leg.text, leg.seconds)
  end
end

if AzerothGPS and (AzerothGPS.version or 0) >= 24 then
  AzerothGPS.API.OnRouteChanged("MyAddon", function(what)
    ShowRoute() -- what: "replanned", "settled" or "cleared"
  end)
end

Standing in for Shortest Path Forever#

While Shortest Path Forever isn't loaded, ShortestPathForever.API is AzerothGPS's answer, so an addon made for it works unchanged:

  • It answers only when Shortest Path Forever isn't loaded. When it is, its own global is never touched.
  • It's read only. Journey(), Guidance(), JourneyState(), Active() and Subscribe() work as above, with version = 2, minor = 4 and provider = "AzerothGPS" to tell it apart.
  • A place there always has a map. A goal off every zone map answers nil, "none".
  • Every call it doesn't answer (planning, steering, estimates) returns nil, "none" instead of an error.
  • When the player turns the option off, the global goes away, and a table kept from before answers nil, "disabled".

One catch: an addon that checks C_AddOns.IsAddOnLoaded("ShortestPathForever") before reading the global won't see AzerothGPS answering. If your addon does that, read AzerothGPS.API when AzerothGPS is loaded. It's the same calls under one new name.

Every field is in the Public API, under "Reading the route".

The route leash (1.4.4)#

For a companion whose player strays off the route on purpose (a mob, a herb, a quest objective), from version 26: check AzerothGPS.version >= 26. Each call takes an owner, your addon's name. Nothing is saved: a /reload forgets it all, and so does ReleaseLeash(owner). A destination the player picks, or one an addon sets with RouteTo and the others, is always routed at once. The leash never applies to it, or to arriving, or to reaching another continent, dungeon or city level.

  • OffRoute(): where the player is against the route's walk right now: yards (how far off), tolerance (the yards allowed there before a reroute), offRoute, along and length (yards along the walk, and its whole length), yardsLeft, the nearest point x, y on level, and held (a hold's reason while one is on). Read only. nil and "none", "loading" or "riding" (on a flight, boat or tram).
  • SetOffRouteTolerance(owner, yards): the yards off the route before AzerothGPS reroutes (30 by default), from 10 to 150. With several addons, the most lenient counts. It's still scaled down in the capitals' and caves' finer grids, as AzerothGPS's own is. nil lets go. OffRouteTolerance(owner) reads it.
  • SetRoadTolerance(owner, value): the "Roads or shortcuts" option (-10 sticks to roads, 10 cuts across) for this session only. The player's own setting is never changed. nil lets go. RoadTolerance() returns the value in use and the player's setting.
  • SetRerouteHold(owner, fn): fn(info) is asked before the whole trip is worked out again because the player left the route. Return "hold", a reason and the seconds to hold (10 by default, 60 at most) to keep the route as it is. Return anything else, or raise an error, and it reroutes as usual. A short stray that rejoins the route ahead never asks. One stray is held for 180 seconds at most in all. Pass "combat" instead of a function to hold only while the player is in combat. info has yards, tolerance, combat, heldSeconds, maxSeconds and the next stop. RerouteHold() returns the hold that's on now.
  • LeashLimits() returns all the bounds, and ReleaseLeash(owner) lets go of everything your addon set.
if AzerothGPS and (AzerothGPS.version or 0) >= 26 then
  AzerothGPS.SetOffRouteTolerance("MyAddon", 60)
  AzerothGPS.SetRerouteHold("MyAddon", function(info)
    if info.combat or MyAddon.gathering then
      return "hold", "gathering", 15
    end
  end)
end

Every field is in the Public API, under "The route leash".