Language:
Lua     Change language:
Pastebin: 99313
Author: Anonymous
Subject: tiptac tal
Created: 2008-10-23 02:45:37
Download and save
Toggle line numbers
1local _G = getfenv(0); 
2 
3TTT_Cache = {}
4local cache = TTT_Cache; 
5local points = {}
6local uToken, val; 
7local lastQuery = 0
8local TALENTS_PREFIX = "Talents:|cffffffff "
9 local tal 
10 
11-- GatherTalents 
12local function GatherTalents(inspect) 
13    for i = 1, 3 do 
14        points[i] = select(3,GetTalentTabInfo(i,inspect)); 
15        if (i == 1) or (points[i] > points[val]) then 
16            val = i; 
17        end 
18    end 
19    -- Set "val" to the desired format 
20    if (points[val] == 0) then 
21        val = "No Talents"
22    else 
23        val = GetTalentTabInfo(val,inspect).." ("..points[1].."/"..points[2].."/"..points[3]..")"
24    end 
25--  val = points[1].."/"..points[2].."/"..points[3]; 
26--  val = GetTalentTabInfo(val,true); 
27    cache.a, cache.b, cache.c = points[1], points[2], points[3]; 
28    for i = 2, GameTooltip:NumLines() do 
29        if ((_G["GameTooltipTextLeft"..i]:GetText() or ""):find("^"..TALENTS_PREFIX)) then 
30            _G["GameTooltipTextLeft"..i]:SetText(TALENTS_PREFIX..val); 
31                    tal:SetText(cache.name.."\n"..val) 
32                    UIFrameFadeIn(tal, 0.3, 0, 1
33            tal.fadeInfo.finishedFunc = function() UIFrameFadeOut(tal, 3, 1, 0) end 
34            GameTooltip:Show(); -- resize 
35            break
36        end 
37    end 
38    -- Organise Cache 
39    for i = 1, #cache do 
40        if (cache.name == cache[i].name) then 
41            tremove(cache,i); 
42            break
43        end 
44    end 
45    if (#cache > 25) then  -- Change cache size here (Default 15) 
46        tremove(cache,1); 
47    end 
48    -- Insert the new entry 
49    tinsert(cache,{ name = cache.name, talents = val }); 
50end 
51 
52-- Event Frame 
53local f = CreateFrame("Frame"); 
54    tal = f:CreateFontString(nil, "OVERLAY"
55    tal:SetPoint("BOTTOM", UIParent, -130, 50
56    tal:SetFontObject(GameFontNormal) 
57    tal:Hide() 
58 
59f:SetScript("OnEvent",function(self,event,...) 
60    f:UnregisterEvent("INSPECT_TALENT_READY"); 
61    GatherTalents(1); 
62--  ClearInspectPlayer(); 
63end); 
64 
65-- HOOK: OnTooltipSetUnit 
66GameTooltip:HookScript("OnTooltipSetUnit"
67function(self,...) 
68    uToken = select(2,self:GetUnit()); 
69    if (not Examiner or not Examiner:IsShown()) and (UnitIsPlayer(uToken)) and (UnitLevel(uToken) > 9 or UnitLevel(uToken) == -1) then 
70        cache.name = UnitName(uToken); 
71        if (UnitIsUnit(uToken,"player")) then 
72            self:AddLine(TALENTS_PREFIX.." Loading..."); 
73            GatherTalents(); 
74        else 
75            local requestInspectData = (CheckInteractDistance(uToken,1) and CanInspect(uToken) and (GetTime() - lastQuery > 0.25)); 
76            if (requestInspectData) then 
77                f:RegisterEvent("INSPECT_TALENT_READY"); 
78                NotifyInspect(uToken); 
79                lastQuery = GetTime(); 
80            end 
81            cache.a, cache.b, cache.c = nil, nil, nil
82            for i = 1, #cache do 
83                if (cache.name == cache[i].name) then 
84                    self:AddLine(TALENTS_PREFIX..cache[i].talents); 
85                    tal:SetText(cache.name.."\n"..cache[i].talents) 
86                    -- tal:Show() 
87                    UIFrameFadeIn(tal, 0.3, 0, 1
88                    tal.fadeInfo.finishedFunc = function() UIFrameFadeOut(tal, 3, 1, 0) end 
89                    cache.a, cache.b, cache.c = cache[i].talents:match("(%d+)/(%d+)/(%d+)"); 
90                    return
91                end 
92            end 
93            if (requestInspectData) then 
94                self:AddLine(TALENTS_PREFIX.." Loading..."); 
95            end 
96        end 
97    end 
98end 
99); 
Download and save
Toggle line numbers
Thread:
[99313] tiptac tal by Anonymous at 2008-10-23 02:45:37
Tip: Click the line numbers to toggle highliting on that line.

Paste followup:

Language:
Author:
Subject:


    Tabstop:     bigger biggest
Note: You can prefix a line with "@@@" to highlight it.