PHP код:
local anchor = CreateFrame("frame", nil, UIParent)
anchor.unit = "player"
anchor.size = 22
anchor.hold = 10
anchor:SetPoint("CENTER", PlayerFrame, "CENTER", 5, 24)
anchor:SetSize(anchor.size, anchor.size)
local OnUpdate = function(self, elapsed)
self.hold = self.hold - elapsed
if self.hold < 0 then
self:Hide()
else
self:SetAlpha(self.hold)
end
end
local CreateIcon = function(self)
local icon = CreateFrame("frame", nil, self)
icon:Hide()
icon:SetSize(self.size, self.size)
local tex = icon:CreateTexture()
tex:SetAllPoints()
icon.tex = tex
icon.hold = 0
icon.parent = self
icon:SetScript("OnUpdate", OnUpdate)
table.insert(self, icon)
return icon
end
local sort = function(a, b)
if a and b then
return a.hold > b.hold
end
end
local UpdatePosition = function(self)
table.sort(self, sort)
for i = 1, #self do
local icon = self[i]
if not icon then return end
icon:ClearAllPoints()
if i == 1 then
icon:SetPoint("CENTER", self, 0, 0)
else
icon:SetPoint("LEFT", self[i-1], "RIGHT", 2, 0)
end
end
end
local UpdateIcons = function(self, unit, limit, texture)
local index = 1
local icon
for i = 1 , limit do
local tmp = self[i] or CreateIcon(self)
if tmp:IsShown() then
index = index + 1
else
icon = self[index]
end
end
icon.tex:SetTexture(texture)
icon.hold = self.hold
icon:SetAlpha(1)
icon:Show()
UpdatePosition(self)
end
anchor:SetScript("OnEvent", function(self, event, unit, spell, rank, ...)
if unit ~= self.unit then return end
local name, rank, texture = GetSpellInfo(spell, rank)
UpdateIcons(self, unit, 10, texture)
end)
anchor:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
Имя себе скрыл: PlayerFrame.name:Hide()