Added a work around for my broken routing code, until its fixed.
[QuestHelper.git] / cartographer.lua
blob54856929227df7fd664bacce05bcd0a6f532888f
1 QuestHelper_File["cartographer.lua"] = "Development Version"
3 local cartographer_cb
4 local cartographer_wp
6 local QuestHelperPoint
8 local function cartographer_wp_update(c, z, x, y, desc)
9 if cartographer_wp then
10 cartographer_wp:Cancel()
11 end
13 if c then
14 cartographer_wp = QuestHelperPoint:new(c, z, x, y, desc)
15 Cartographer_Waypoints:AddWaypoint(cartographer_wp)
16 end
17 end
19 function QuestHelper:EnableCartographer()
20 if Cartographer_Waypoints and Waypoint and not Waypoint.prototype then
21 if not QuestHelperPoint then
22 QuestHelperPoint = Waypoint:new()
23 QuestHelperPoint.ShowOnMap = false
25 function QuestHelperPoint:init(c, z, x, y, desc)
26 self.x, self.y, self.task = x, y, desc
28 local zone = select(z, GetMapZones(c))
30 if Rock then
31 local LibBabble = Rock("LibBabble-Zone-3.0", false, true)
32 if LibBabble then
33 zone = LibBabble:GetReverseLookupTable()[zone]
34 end
35 end
37 self.Zone = zone
38 end
40 function QuestHelperPoint:Cancel()
41 self.task = nil
43 if cartographer_wp == self then
44 cartographer_wp = nil
45 end
47 Waypoint.Cancel(self)
48 end
50 function QuestHelperPoint:ToString()
51 return self.task or "Waypoint"
52 end
53 end
55 if not cartographer_cb then
56 cartographer_cb = QuestHelper:AddWaypointCallback(cartographer_wp_update)
57 end
58 end
59 end
61 function QuestHelper:DisableCartographer()
62 if cartographer_cb then
63 if cartographer_wp then
64 cartographer_wp:Cancel()
65 end
67 QuestHelper:RemoveWaypointCallback(cartographer_cb)
68 cartographer_cb = nil
69 end
70 end