WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   UnitThreat not working (https://www.wowinterface.com/forums/showthread.php?t=56175)

GreyFox777 04-24-18 07:26 AM

UnitThreat not working
 
can anyone tell, why does this code not working? Im trying to get the frame load if the party unit has threat >0

Quote:

...
...
table.insert(self.__elements, function(self, _, unit, event, ...)
local status = UnitThreatSituation(unit)
if (unit == 'party1') or (unit == 'party2') or (unit == 'party3') or (unit == 'party4') then
if status and status >0 then
frame_3texture:SetTexture(m.textures.frame_3)

frame_3texture:Show()

else
frame_3texture:Hide()
end
end
end)
frame_3texture:SetPoint('CENTER', self, 'CENTER', 22, -2)
frame_3texture:SetSize(256,128)
frame_3texture:SetTexCoord(1, 0, 0, 1)
But It just does nothing

neverg 04-24-18 08:58 AM

Could you use the LUA highlight capability of the forum?
Makes the snippets way easier to read.

You have a button in the toolbar.
[ highlight="Lua" ] [ /highlight ]

Hard to debug a piece of code in isolation and you didn't say exactly what is not working.

What I can tell you is that you need to register the Threat Events against a callback in order for you to see any updates.
Like so:

Lua Code:
  1. local function UpdateThreat(self, event, unit)
  2.  -- Do stuff here
  3. end
  4.  
  5. frame:RegisterEvent("UNIT_THREAT_LIST_UPDATE", UpdateThreat)
  6. frame:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE", UpdateThreat)


All times are GMT -6. The time now is 02:29 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI