WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Set PowerBarColor without taint? (https://www.wowinterface.com/forums/showthread.php?t=54159)

thomasjohnshannon 08-08-16 02:55 AM

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}

Vlad 08-08-16 04:17 AM

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

Seerah 08-08-16 11:55 AM

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).

thomasjohnshannon 08-08-16 03:32 PM

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.

Phanx 08-08-16 05:04 PM

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.

thomasjohnshannon 08-08-16 06:45 PM

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.

Phanx 08-08-16 10:43 PM

Quote:

Originally Posted by thomasjohnshannon (Post 317689)
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.

thomasjohnshannon 08-09-16 12:14 AM

Quote:

Originally Posted by Phanx (Post 317707)
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).

lightspark 08-09-16 02:20 AM

Quote:

Originally Posted by thomasjohnshannon (Post 317711)
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 :D

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

Phanx 08-09-16 08:38 AM

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

badness 08-09-16 09:36 AM

Quote:

Originally Posted by Phanx (Post 317722)
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 :D


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

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI