Thread Tools Display Modes
08-08-16, 02:55 AM   #1
thomasjohnshannon
A Theradrim Guardian
 
thomasjohnshannon's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 68
Set PowerBarColor without taint?

Is it possible to set PowerBarColor["MANA"] without taint?

I'm currently using.

Code:
_G.PowerBarColor["MANA"] = {r = 0/255, g = 0.55, b = 1}
__________________
Thomas aka Urnn

Last edited by thomasjohnshannon : 08-08-16 at 03:08 AM.
  Reply With Quote
08-08-16, 04:17 AM   #2
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
Does things still break if you do this?

Code:
local t = _G.PowerBarColor["MANA"]
t.r, t.g, t.b = 0/255, 140/255, 255/255
*Edit* Good read about taint:
http://wow.gamepedia.com/Secure_Execution_and_Tainting
__________________
Profile: Curse | Wowhead
  Reply With Quote
08-08-16, 11:55 AM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Taint in and of itself is fine, and is going to happen. It just means that non-Blizzard code touched something in Blizzard code. When to worry about it is when it causes an action blocked error, which means that Blizzard's secure code was tainted (either directly or through a chain reaction).
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
08-08-16, 03:32 PM   #4
thomasjohnshannon
A Theradrim Guardian
 
thomasjohnshannon's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 68
The color of mana isn't a big issues but it would be nice to get it working. I'm getting this lua error with my code and the code that was suggested by Vlad.

Code:
1x [ADDON_ACTION_BLOCKED] AddOn '!Colorz' tried to call the protected function 'CompactRaidFrame28:Show()'.
!BugGrabber\BugGrabber.lua:573: in function <!BugGrabber\BugGrabber.lua:573>
[C]: in function `Show'
FrameXML\CompactUnitFrame.lua:330: in function `CompactUnitFrame_UpdateVisible'
FrameXML\CompactUnitFrame.lua:280: in function `CompactUnitFrame_UpdateAll'
FrameXML\CompactUnitFrame.lua:115: in function <FrameXML\CompactUnitFrame.lua:51>

Locals:
I'm getting similar errors showing up in the taint log but the one thing they have in common is CompactRaidFrame showing up in all of them and the only time the error shows up is when the default raid frames are running.

The funny party is the addon overwrites entire functions and it doesn't care at all but add that one line to change a variable and it has a problem.

I'm working on !Colorz if you want to see the full code.
__________________
Thomas aka Urnn
  Reply With Quote
08-08-16, 05:04 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You will most likely have to use secure hooks. For an example, here is the function I use in !ClassColors to apply custom class colors to the health bars of the default raid frames:

lua Code:
  1. hooksecurefunc("CompactUnitFrame_UpdateHealthColor", function(frame)
  2.     if frame.optionTable.useClassColors and UnitIsConnected(frame.unit) then
  3.         local _, class = UnitClass(frame.unit)
  4.         if class then
  5.             local color = CUSTOM_CLASS_COLORS[class]
  6.             if color then
  7.                 frame.healthBar:SetStatusBarColor(color.r, color.g, color.b)
  8.             end
  9.         end
  10.     end
  11. end)

You'll need to change the function, object, and table names, but otherwise it should be pretty similar. You can't modify the original table at all, so you'll need to add a bunch more hooks to apply your custom colors to power bars in other parts of the UI as well.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-08-16, 06:45 PM   #6
thomasjohnshannon
A Theradrim Guardian
 
thomasjohnshannon's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 68
Hooking UnitFrameManaBar_UpdateType would work for the default unit frames but I had to go into the oUF layouts and manually check for mana to fix them.
__________________
Thomas aka Urnn

Last edited by thomasjohnshannon : 08-08-16 at 06:47 PM.
  Reply With Quote
08-08-16, 10:43 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by thomasjohnshannon View Post
Hooking UnitFrameManaBar_UpdateType would work for the default unit frames but I had to go into the oUF layouts and manually check for mana to fix them.
You should just need to modify the values in the oUF.colors.power table to affect oUF layouts. Simple taint doesn't break addons, because they're already assumed to be tainted by default.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-09-16, 12:14 AM   #8
thomasjohnshannon
A Theradrim Guardian
 
thomasjohnshannon's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 68
Originally Posted by Phanx View Post
You should just need to modify the values in the oUF.colors.power table to affect oUF layouts. Simple taint doesn't break addons, because they're already assumed to be tainted by default.
Is it possible to set the oUF.colors.power table from inside the layout? Because I'm not just working on this for personal use and would rather not maintain a custom version of oUF (even with that project being a bit fractured atm).
__________________
Thomas aka Urnn
  Reply With Quote
08-09-16, 02:20 AM   #9
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Originally Posted by thomasjohnshannon View Post
Is it possible to set the oUF.colors.power table from inside the layout? Because I'm not just working on this for personal use and would rather not maintain a custom version of oUF (even with that project being a bit fractured atm).
Yes, it's possible to do so. It's a question of the day, haha, another person has asked me about it via PM

Lua Code:
  1. local _, ns = ...
  2. local oUF = ns.oUF
  3. oUF.colors.power["ARCANE_CHARGES"] = {29 / 255, 124 / 255, 226 / 255}
  4. -- and so on
__________________

Last edited by lightspark : 08-09-16 at 02:24 AM.
  Reply With Quote
08-09-16, 08:38 AM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Depending on the layout, there may not be an "ns.oUF", but instead a global "oUF". To account for both possibilities (without changing anything else in the layout) that second line should be:

Code:
local oUF = ns.oUF or oUF
You can see how I change the power colors for mana and runic power in my oUF layout here:
https://github.com/Phanx/oUF_Phanx/b.../Core.lua#L220
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-09-16, 09:36 AM   #11
badness
A Cliff Giant
 
badness's Avatar
Join Date: May 2010
Posts: 74
Originally Posted by Phanx View Post
Depending on the layout, there may not be an "ns.oUF", but instead a global "oUF". To account for both possibilities (without changing anything else in the layout) that second line should be:

Code:
local oUF = ns.oUF or oUF
You can see how I change the power colors for mana and runic power in my oUF layout here:
https://github.com/Phanx/oUF_Phanx/b.../Core.lua#L220
Thanks Phanx..your example worked for me
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Set PowerBarColor without taint?

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