Reply
Thread Tools Display Modes
Unread 11-23-12, 06:20 AM   #1
Hahatoon
A Defias Bandit
Join Date: Nov 2012
Posts: 2
Question 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
Hahatoon is offline   Reply With Quote
Unread 11-23-12, 09:16 AM   #2
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 762
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.
__________________
Profile: Curse | Wowhead
Vlad is offline   Reply With Quote
Unread 11-23-12, 10:24 AM   #3
brotherhobbes
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 313
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.
brotherhobbes is offline   Reply With Quote
Unread 11-24-12, 07:37 AM   #4
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 762
I encourage him trying to code his own code!
__________________
Profile: Curse | Wowhead
Vlad is offline   Reply With Quote
Unread 12-07-12, 09:13 AM   #5
Hahatoon
A Defias Bandit
Join Date: Nov 2012
Posts: 2
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.

Last edited by Hahatoon : 12-07-12 at 10:02 AM.
Hahatoon is offline   Reply With Quote
Unread 12-07-12, 01:44 PM   #6
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 243
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".

Last edited by Clamsoda : 12-07-12 at 01:49 PM.
Clamsoda is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Lua/XML Help » ShowOverlayGlow

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off