WoWInterface

WoWInterface (http://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (http://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   ShowOverlayGlow (http://www.wowinterface.com/forums/showthread.php?t=45216)

Hahatoon 11-23-12 06:20 AM

ShowOverlayGlow
 
Hi! I'm new to Lua :( I'm trying to apply WoW ingame proc glow effect to ActionButton if player has a certain buff.

Here is the code

Code:

frame = CreateFrame("Frame")
frame:SetScript("OnUpdate", function(self, elapsed)
        if ( UnitBuff("player", "Molten Armor") ) then
                ActionButton_ShowOverlayGlow(ActionButton1)
        else
                ActionButton_HideOverlayGlow(ActionButton1)
        end
end)

If player has Molten Armor then add glow effect to ActionButton1 else dont show glow effect at all.

This code is not working for me. Need help :)

Vlad 11-23-12 09:16 AM

Thumbs up for trying!

Thing is you are looking out for a buff application, and you have a event for that that you can use (much better than having a OnUpdate script, because that runs each frame, not very necessary).

You need the event UNIT_AURA, a frame to work with and since this is a UNIT_* event we can use RegisterUnitEvent.

Code:

local f = CreateFrame("Frame")
f:RegisterUnitEvent("UNIT_AURA", "player")
f:SetScript("OnEvent", function()
  if UnitBuff("player", "Molten Armor") then
    ActionButton_ShowOverlayGlow(ActionButton1)
  else
    ActionButton_HideOverlayGlow(ActionButton1)
  end
end)

ActionButton1 is only for the default action bar, if you use an addon then you need to /fstack and find the frame name of your button. ;)

brotherhobbes 11-23-12 10:24 AM

If you'd rather have an addon do this for you, check out Inline Aura -> http://www.curse.com/addons/wow/inline-aura

You can set it to do exactly what you want.

Vlad 11-24-12 07:37 AM

I encourage him trying to code his own code! ;)

Hahatoon 12-07-12 09:13 AM

Thanks for help! But it worked for me only with this code

Code:

local f = CreateFrame("Button") --Button instead Frame
f:RegisterUnitEvent("UNIT_AURA", "player")
f:SetScript("OnEvent", function()
  if UnitBuff("player", "Molten Armor") then
    ActionButton_HideOverlayGlow(ActionButton1) --Reverse than and else
  else
    ActionButton_ShowOverlayGlow(ActionButton1)
  end
end)

Could you explain me the "Reverse then and else" ? Looks like a bug or smth.

Clamsoda 12-07-12 01:44 PM

I just did a bit of testing, and the posted code SHOULD work. I should say it worked for Blessing of Kings, and assuming Molten Armor is spelled correctly, and you are using the default Blizzard action bars, or an addon that reuses Blizzard's buttons, it should work for you as well.

This code should be exactly the same as Vlad's, I just copy and pasted what was working for me.
Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterUnitEvent("UNIT_AURA", "player")
  3. f:SetScript("OnEvent", function()
  4.   if UnitBuff("player", "Molten Armor") then
  5.     ActionButton_ShowOverlayGlow(ActionButton1)
  6.   else
  7.     ActionButton_HideOverlayGlow(ActionButton1)
  8.   end
  9. end)

Also, in response to one of your changes, you don't need to define your frame "f" as a Button, unless you are trying to inherit certain properties of buttons. All you are doing is creating, and using a frame to register and watch for events.

EDIT: I also wanted to make sure that it is clear to you that "ActionButton1" is specifying to add the OverlayGlow to the first button, on the first(main) action bar. If you wanted it on the 5th button, it would be "ActionButton5", and if you wanted it on the 3rd button of the MultiBarBotttomRight action bar, it would be "MultiBarBotttomRightButton3".


All times are GMT -6. The time now is 05:23 AM.

vBulletin © 2014, Jelsoft Enterprises Ltd
©2012 ZAM Network LLC