-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMapTarget.lua
More file actions
executable file
·93 lines (78 loc) · 1.69 KB
/
MapTarget.lua
File metadata and controls
executable file
·93 lines (78 loc) · 1.69 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
local click_orig = nil
local escapes = {
["|c%x%x%x%x%x%x%x%x"] = "", -- color start
["|r"] = "", -- color end
["|H.-|h(.-)|h"] = "%1", -- links
["|T.-|t"] = "", -- textures
}
local function unescape(str)
for k, v in pairs(escapes) do
str = gsub(str, k, v)
end
return str
end
local function getlines(text)
text = text .. "\n"
local lines = {}
local index = 1
local pos = 0
while true do
local newpos = strfind(text, "\n", pos, true)
if not newpos then
break
end
local line = strsub(text, pos, newpos - 1)
if line ~= "" then
lines[index] = line
index = index + 1
end
pos = newpos + 1
end
return lines
end
local function filter(name)
if strfind(name, " ") then
return false
end
return true
end
local click_target = function()
local text = getglobal("GameTooltipTextLeft1"):GetText()
if not text then return end
local names = getlines(text)
local selected = 1
for i, name in names do
local uname = unescape(name)
names[i] = uname
if filter(uname) then
selected = i
end
end
TargetByName(names[selected], true)
end
local click_new = function()
local shift = IsShiftKeyDown()
if SpellIsTargeting() or shift or IsControlKeyDown() or IsAltKeyDown() then
local x, y = GetCursorPosition()
x = x / this:GetEffectiveScale()
y = y / this:GetEffectiveScale()
local cx, cy = this:GetCenter()
x = x - cx
y = y - cy
if shift then
x = x * 5
y = y * 5
end
x = x + CURSOR_OFFSET_X
y = y + CURSOR_OFFSET_Y
Minimap:PingLocation(x, y)
--DEFAULT_CHAT_FRAME:AddMessage("Ping: " .. x .. " " .. y)
else
click_target()
end
end
local setup = function()
click_orig = Minimap_OnClick
Minimap_OnClick = click_new
end
setup()