/Tukui/modules/datatext/crit.lua

http://github.com/Asphyxia/Tukui · Lua · 37 lines · 29 code · 5 blank · 3 comment · 6 complexity · 4a5daf5e146f5e225444b4834a7859a6 MD5 · raw file

  1. local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
  2. --------------------------------------------------------------------
  3. -- Crit (Spell or Melee.. or ranged)
  4. --------------------------------------------------------------------
  5. if C["datatext"].crit and C["datatext"].crit > 0 then
  6. local Stat = CreateFrame("Frame")
  7. Stat:SetFrameStrata("HIGH")
  8. Stat:SetFrameLevel(3)
  9. local Text = TukuiInfoLeft:CreateFontString(nil, "OVERLAY")
  10. Text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  11. T.PP(C["datatext"].crit, Text)
  12. local int = 1
  13. local function Update(self, t)
  14. int = int - t
  15. meleecrit = GetCritChance()
  16. spellcrit = GetSpellCritChance(1)
  17. rangedcrit = GetRangedCritChance()
  18. if spellcrit > meleecrit then
  19. CritChance = spellcrit
  20. elseif select(2, UnitClass("Player")) == "HUNTER" then
  21. CritChance = rangedcrit
  22. else
  23. CritChance = meleecrit
  24. end
  25. if int < 0 then
  26. Text:SetText(SPELL_CRIT_CHANCE..": "..T.datacolor..format("%.2f", CritChance) .. "%")
  27. int = 1
  28. end
  29. end
  30. Stat:SetScript("OnUpdate", Update)
  31. Update(Stat, 10)
  32. end