Trying to write a script for eePanels2 here and I need a little help.
The idea is to change the background colour of a frame based on the targets hostility towards you using the "UnitReaction" API function key.
For example if the target was hostile towards you the frame would be red, if they neutral the frame would be yellow and if they were friendly the frame would be green. I have tried to find as much info as I can on this function key but to be honest there is not much available.
Now I am no coder (that’s where you guys come in) but this is what I have so far. I expect it is far far from being correct but any help or advice any one could offer would be great.
Code:
function eepanels2:local reaction = UnitReaction(unit, "player");
if (reaction) then
if reaction >=5 then
eePanels2.db.profile.panels[4].background.frame:SetGradientAlpha("VERTICAL", 0, 1, 0, 1, 0, 1, 0, 1)
elseif reaction = 4 then
eePanels2.db.profile.panels[4].background.frame:SetGradientAlpha("VERTICAL", 0, 1, 1, 1, 0, 1, 1, 1)
elseif reaction <=3 then
eePanels2.db.profile.panels[4].background.frame:SetGradientAlpha("VERTICAL", 1, 0, 0, 1, 1, 0, 0, 1)
end
end
eePanels2:RegisterEvent("REACTION_FRIENDLY")
eePanels2:RegisterEvent("REACTION_NEUTRAL")
eePanels2:RegisterEvent("REACTION_HOSTILE")
When I get this basic part worked out I would also like to add some other colours for dead/ghost target, friendly players etc.