-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpin.lua
51 lines (41 loc) · 1.28 KB
/
pin.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
local checkPinSupport, placePin
function SlashPin:Pin(x, y, uiMapID)
if not SlashPin:ValidateCoordinates(x, y) then
SlashPin:Error("Coordinates out of bounds.")
return
end
if uiMapID == nil then
uiMapID = SlashPin:GetUiMapIDForCurrentZone()
end
if checkPinSupport(uiMapID) then
placePin(x, y, uiMapID)
end
end
function SlashPin:PinHere()
local uiMapID = SlashPin:GetUiMapIDForCurrentZone()
if checkPinSupport(uiMapID) then
local position = C_Map.GetPlayerMapPosition(uiMapID, "player")
local x, y = position:GetXY()
placePin(x, y, uiMapID)
end
end
function SlashPin:Clear()
C_Map.ClearUserWaypoint()
PlaySound(SOUNDKIT.UI_MAP_WAYPOINT_REMOVE)
end
function checkPinSupport(uiMapID)
if C_Map.CanSetUserWaypointOnMap(uiMapID) then
return true
else
SlashPin:Error("This zone does not support placing pins.")
return false
end
end
function placePin(x, y, uiMapID)
local point = UiMapPoint.CreateFromCoordinates(uiMapID, x, y)
C_Map.SetUserWaypoint(point)
PlaySound(SOUNDKIT.UI_MAP_WAYPOINT_CONTROL_CLICK)
-- TODO make automatic tracking optional
C_SuperTrack.SetSuperTrackedUserWaypoint(true)
PlaySound(SOUNDKIT.UI_MAP_WAYPOINT_SUPER_TRACK_ON)
end