Thread: Stuf + Threat
View Single Post
06-09-11, 03:57 PM   #2
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Lily.Petal View Post
I am currently wanting to make a small threat meter using Stuf's custom LUA text option.

All I want it to do is just show My current Threat% (without the % sign please) on my target, the color being Stuf's HP Red Color.

If someone could offer assistance, I would appreciate it greatly!

*~Lily.Petal~*
To get an accurate % reading may be out of the scope of Lua Text, as you'd want a timer to keep threat information updated. There's a few threat events you can watch out for, but they only fire on major threat changes making them somewhat useless for watching threat closely. It may be possible to utilize Stufs own Target frame from within the Lua Text itself. A crude example being:

Code:
self.ttelapsed = 0
self:SetScript("OnUpdate", function(self, elapsed)
  self.ttelapsed = self.ttelapsed + elapsed
  if self.ttelapsed >= 0.5 then
    local _, _, threatpct, _, threatvalue = UnitDetailedThreatSituation(unitid, mobunitid)
    if threatvalue then
      return "|cffff0000%d|r", floor(threatpct)
    else
      return ""
    end
    self.ttelapsed = 0
  end
end)
  Reply With Quote