PageRenderTime 65ms CodeModel.GetById 40ms app.highlight 2ms RepoModel.GetById 18ms app.codeStats 0ms

/Tukui/modules/datatext/crit.lua

http://github.com/Asphyxia/Tukui
Lua | 37 lines | 29 code | 5 blank | 3 comment | 4 complexity | 4a5daf5e146f5e225444b4834a7859a6 MD5 | raw file
 1local 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
 6if C["datatext"].crit and C["datatext"].crit > 0 then
 7	local Stat = CreateFrame("Frame")
 8	Stat:SetFrameStrata("HIGH")
 9	Stat:SetFrameLevel(3)
10
11	local Text  = TukuiInfoLeft:CreateFontString(nil, "OVERLAY")
12	Text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
13	T.PP(C["datatext"].crit, Text)
14
15	local int = 1
16
17	local function Update(self, t)
18		int = int - t
19		meleecrit = GetCritChance()
20		spellcrit = GetSpellCritChance(1)
21		rangedcrit = GetRangedCritChance()
22		if spellcrit > meleecrit then
23			CritChance = spellcrit
24		elseif select(2, UnitClass("Player")) == "HUNTER" then    
25			CritChance = rangedcrit
26		else
27			CritChance = meleecrit
28		end
29		if int < 0 then
30			Text:SetText(SPELL_CRIT_CHANCE..": "..T.datacolor..format("%.2f", CritChance) .. "%")
31			int = 1
32		end     
33	end
34
35	Stat:SetScript("OnUpdate", Update)
36	Update(Stat, 10)
37end