PHP код:
local frame = CreateFrame("StatusBar",nil,UIParent)
frame:SetSize(32,32)
frame:SetPoint("CENTER",140,140)
frame:SetStatusBarTexture([[Interface\Buttons\WHITE8X8]])
frame:SetStatusBarColor(0,0,0,0.75)
frame:SetOrientation("VERTICAL")
frame:SetMinMaxValues(0,3)
local icon = frame:CreateTexture(nil,"BORDER")
icon:SetAllPoints()
icon:SetTexCoord(0.07,0.93,0.07,0.93)
icon:SetTexture([[Interface\Icons\Spell_Nature_TremorTotem]])
local bg = frame:CreateTexture(nil,"BACKGROUND")
bg:SetPoint("TOPRIGHT",frame,"TOPRIGHT",2,2)
bg:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",-2,-2)
bg:SetTexture([[Interface\Buttons\WHITE8X8]])
bg:SetVertexColor(0,0,0)
local GetTime = GetTime
local summonTime
frame:SetScript("OnUpdate",function(self)
self:SetValue((GetTime()-summonTime)%3)
end)
local COMBATLOG_OBJECT_REACTION_HOSTILE = COMBATLOG_OBJECT_REACTION_HOSTILE
local band = bit.band
local totemGUID
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:SetScript("OnEvent",function(self,event,_,subEvent,...)
if event=="PLAYER_ENTERING_WORLD" then
self:Hide()
else
if subEvent=="SPELL_SUMMON" then
local _,_,srcFlags,objGUID,_,_,spellid = ...
if band(srcFlags,COMBATLOG_OBJECT_REACTION_HOSTILE)~=0 and spellid==8143 then
summonTime,totemGUID = GetTime(),objGUID
self:Show()
end
elseif subEvent=="UNIT_DIED" then
local _,_,_,objGUID = ...
if objGUID==totemGUID then
self:Hide()
end
end
end
end)