PageRenderTime 15ms CodeModel.GetById 13ms RepoModel.GetById 0ms 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
  1. local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
  2. if C["chat"].enable ~= true then return end
  3. -- /tt - tell your current target.
  4. for i = 1, NUM_CHAT_WINDOWS do
  5. local editBox = _G["ChatFrame"..i.."EditBox"]
  6. editBox:HookScript("OnTextChanged", function(self)
  7. local text = self:GetText()
  8. if text:len() < 5 then
  9. if text:sub(1, 4) == "/tt " then
  10. local unitname, realm
  11. unitname, realm = UnitName("target")
  12. if unitname then unitname = gsub(unitname, " ", "") end
  13. if unitname and not UnitIsSameServer("player", "target") then
  14. unitname = unitname .. "-" .. gsub(realm, " ", "")
  15. end
  16. ChatFrame_SendTell((unitname or L.chat_invalidtarget), ChatFrame1)
  17. end
  18. end
  19. end)
  20. end