PageRenderTime 43ms CodeModel.GetById 39ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Tukui/modules/chat/telltarget.lua

http://github.com/Asphyxia/Tukui
Lua | 21 lines | 19 code | 1 blank | 1 comment | 7 complexity | c5c0d97668efb1b279307f08e401392d MD5 | raw file
 1local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
 2if C["chat"].enable ~= true then return end
 3
 4-- /tt - tell your current target.
 5for i = 1, NUM_CHAT_WINDOWS do
 6	local editBox = _G["ChatFrame"..i.."EditBox"]
 7	editBox:HookScript("OnTextChanged", function(self)
 8	   local text = self:GetText()
 9	   if text:len() < 5 then
10		  if text:sub(1, 4) == "/tt " then
11			 local unitname, realm
12			 unitname, realm = UnitName("target")
13			 if unitname then unitname = gsub(unitname, " ", "") end
14			 if unitname and not UnitIsSameServer("player", "target") then
15				unitname = unitname .. "-" .. gsub(realm, " ", "")
16			 end
17			 ChatFrame_SendTell((unitname or L.chat_invalidtarget), ChatFrame1)
18		  end
19	   end
20	end)
21end