-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlinkerator.lua
39 lines (35 loc) · 939 Bytes
/
linkerator.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
--[[
linkerator.lua
Linkerator functionality for adapted for Ludwig
Thanks to N00bZXI for the autocomplete changes
--]]
local function OnFullMatch(match)
local list = Ludwig:GetItemsNamedLike(match)
if list and list[1] then
return (select(2, GetItemInfo(list[1])))
end
return match
end
local function OnPartialMatch(match)
local list = Ludwig:GetItemsNamedLike(match)
if list and list[1] then
return '[[' .. GetItemInfo(list[1])
end
return '[[' .. match
end
local function Linkerator_OnChar(self, ...)
local text = self:GetText()
if text ~= '' then
if text:match('%[%[(.+)%]') then
self:SetText(text:gsub('%[%[(.+)%]', OnFullMatch))
else
self:SetText(text:gsub('%[%[(.+)', OnPartialMatch))
self:HighlightText(#text, -1)
end
end
end
if ChatFrameEditBox:GetScript('OnChar') then
ChatFrameEditBox:HookScript('OnChar', Linkerator_OnChar)
else
ChatFrameEditBox:SetScript('OnChar', Linkerator_OnChar)
end