Thread Tools Display Modes
11-15-15, 05:25 AM   #21
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
All I did there was modify the last code that was posted in that thread and change "self" to "bar". If you're getting an error, refer to Fizzlemizz's posts and make whatever changes are necessary for the specific addon you're attaching your panel to.

If you previously had some version of it working, just change "self" to "bar" where it's highlighed in my post, and leave "self.bg" as "self.bg" instead of changing it to your panel's name.

If it's still not working, you'll have to wait for someone who actually uses your unitframe addon to post with the correct name/path to use for it.
__________________
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
11-15-15, 09:39 AM   #22
Soulcleaver
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 65
Originally Posted by Phanx View Post
All I did there was modify the last code that was posted in that thread and change "self" to "bar". If you're getting an error, refer to Fizzlemizz's posts and make whatever changes are necessary for the specific addon you're attaching your panel to.

If you previously had some version of it working, just change "self" to "bar" where it's highlighed in my post, and leave "self.bg" as "self.bg" instead of changing it to your panel's name.

If it's still not working, you'll have to wait for someone who actually uses your unitframe addon to post with the correct name/path to use for it.
ok.. so i went back and tried alitte..

I ended up with it working.. but i will allways get a error on my first target when i log in, then it works on and after my 2nd target.

error code
Code:
Message: [string "Targetbottom_OnEvent"]:1: attempt to index field 'hpbar' (a nil value)
Time: 11/15/15 16:37:41
Count: 1
Stack: [string "Targetbottom_OnEvent"]:1: in function <[string "Targetbottom_OnEvent"]:1>
[C]: in function `CameraOrSelectOrMoveStop'
[string "CAMERAORSELECTORMOVE"]:4: in function <[string "CAMERAORSELECTORMOVE"]:1>

Locals: self = kgPanel60 {
 0 = <userdata>
 _backdrop_options = <table> {
 }
 _GetBackdropColor = <function> defined =[C]:-1
 SetBackdropGradientAlpha = <function> defined @Interface\AddOns\kgPanels\Libs\LibBackdrop-1.0\LibBackdrop-1.0.lua:535
 _SetBackdrop = <function> defined =[C]:-1
 GetBackdropBorderSection = <function> defined @Interface\AddOns\kgPanels\Libs\LibBackdrop-1.0\LibBackdrop-1.0.lua:155
 GetBackdropColor = <function> defined =[C]:-1
 _backdrop = <unnamed> {
 }
 _GetBackdropBorderColor = <function> defined =[C]:-1
 SetBackdropBorderColor = <function> defined =[C]:-1
 bg = <unnamed> {
 }
 missing_anchor_at_load = false
 missing_parent_at_load = false
 scripts_loaded = false
 SetBackdropBorderGradientAlpha = <function> defined @Interface\AddOns\kgPanels\Libs\LibBackdrop-1.0\LibBackdrop-1.0.lua:568
 GetBackdropBackground = <function> defined @Interface\AddOns\kgPanels\Libs\LibBackdrop-1.0\LibBackdrop-1.0.lua:147
 text = <unnamed> {
 }
 _SetBackdropColor = <function> defined =[C]:-1
 BorderTextureFunction = <function> defined @Interface\AddOns\kgPanels\Libs\LibBackdrop-1.0\LibBackdrop-1.0.lua:136
 SetBackdrop = <function> defined =[C]:-1
 GetBackdropBorderColor = <function> defined =[C]:-1
 _GetBackdrop = <function> defined =[C]:-1
 GetBackdrop = <function> defined =[C]:-1
 SetBackdropBorderGradient = <function> defined @Interface\AddOns\kgPanels\Libs\LibBackdrop-1.0\LibBackdrop-1.0.lua:542
 _SetBackdropBorderColor = <function> defined =[C]:-1
 SetBackdropColor = <function> defined =[C]:-1
 SetBackdropGradient = <function> defined @Interface\AddOns\kgPanels\Libs\LibBackdrop-1.0\LibBackdrop-1.0.lua:528
}
event = "PLAYER_TARGET_CHANGED"
arg1 = nil
arg2 = nil
arg3 = nil
arg4 = nil
arg5 = nil
arg6 = nil
arg7 = nil
arg8 = nil
arg9 = nil
arg10 = nil
kgPanels = <table> {
 SetDefaultModuleLibraries = <function> defined @Interface\AddOns\ColorPickerPlus\libs\Ace3\AceAddon-3.0\AceAddon-3.0.lua:398
 FetchFont = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:378
 SetupScript = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:1010
 Enable = <function> defined @Interface\AddOns\ColorPickerPlus\libs\Ace3\AceAddon-3.0\AceAddon-3.0.lua:325
 RegisterChatCommand = <function> defined @Interface\AddOns\Dominos\libs\AceConsole-3.0\AceConsole-3.0.lua:85
 EnableModule = <function> defined @Interface\AddOns\ColorPickerPlus\libs\Ace3\AceAddon-3.0\AceAddon-3.0.lua:363
 modules = <table> {
 }
 GetModule = <function> defined @Interface\AddOns\ColorPickerPlus\libs\Ace3\AceAddon-3.0\AceAddon-3.0.lua:241
 IterateEmbeds = <function> defined @Interface\AddOns\ColorPickerPlus\libs\Ace3\AceAddon-3.0\AceAddon-3.0.lua:473
 ResetFont = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:992
 defaultModuleLibraries = <table> {
 }
 eframe = kgPanels_Dep_Frame {
 }
 UnregisterChatCommand = <function> defined @Interface\AddOns\Dominos\libs\AceConsole-3.0\AceConsole-3.0.lua:111
 Printf = <function> defined @Interface\AddOns\Dominos\libs\AceConsole-3.0\AceConsole-3.0.lua:69
 angles = <table> {
 }
 GetName = <function> defined @Interface\AddOns\ColorPickerPlus\libs\Ace3\AceAddon-3.0\AceAddon-3.0.lua:310
 AddMissingMedia = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:463
 ReParent = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:717
 name = "kgPanels"
 FetchArt = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:375
 IsEnabled = <function> defined @Interface\AddOns\ColorPickerPlus\libs\Ace3\AceAddon-3.0\AceAddon-3.0.lua:482
 orderedModules = <table> {
 }
 CommandLine = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:612
 DisableModule = <function> defined
what i ended up using.

onload

self:RegisterEvent("PLAYER_TARGET_CHANGED")

onEvent

hooksecurefunc(Stuf.units.target.hpbar.bar, "SetVertexColor", function(bar, ...)
self.bg:SetVertexColor(...)
end)

Something im missing or something i can do to make the error go away ?
  Reply With Quote
11-15-15, 11:15 AM   #23
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
The error seems to be because Stuff creates the target hpbar "on demand" the first time you select a target. Phanx might have a better method but you could change it too:

Code:
if Stuf.units.target.hpbar and Stuf.units.target.hpbar.bar then
	hooksecurefunc(Stuf.units.target.hpbar.bar, "SetVertexColor", function(bar, ...)
		self.bg:SetVertexColor(...)
	end)
	self:UnregisterEvent("PLAYER_TARGET_CHANGED")
end
This might not account for changing the color the first (second?) time you select a target which might need something extra.

Edit: Fixed typo for future references as per Phanx's comment below.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 11-15-15 at 03:19 PM.
  Reply With Quote
11-15-15, 02:33 PM   #24
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Watch your shift key -- Lua is case sensitive, so "UnRegisterEvent" isn't the same as "UnregisterEvent" and will raise an error because it doesn't exist.

Otherwise, you can just grab the color and set it immediately:

Code:
if Stuf.units.target.hpbar and Stuf.units.target.hpbar.bar then
	hooksecurefunc(Stuf.units.target.hpbar.bar, "SetVertexColor", function(bar, ...)
		self.bg:SetVertexColor(...)
	end)
	self.bg:SetVertexColor(Stuf.units.target.hpbar.bar:GetVertexColor())
	self:UnregisterEvent("PLAYER_TARGET_CHANGED")
end
__________________
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
11-15-15, 02:47 PM   #25
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
Watch your shift key...
There's a reason for my avatar title

This may still only cure setting the colour when selecting the second target if the panel receives the target change event before Stuf has created the bar when selecting the first.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
11-15-15, 02:49 PM   #26
Soulcleaver
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 65
Originally Posted by Phanx View Post
Watch your shift key -- Lua is case sensitive, so "UnRegisterEvent" isn't the same as "UnregisterEvent" and will raise an error because it doesn't exist.

Otherwise, you can just grab the color and set it immediately:

Code:
if Stuf.units.target.hpbar and Stuf.units.target.hpbar.bar then
	hooksecurefunc(Stuf.units.target.hpbar.bar, "SetVertexColor", function(bar, ...)
		self.bg:SetVertexColor(...)
	end)
	self.bg:SetVertexColor(Stuf.units.target.hpbar.bar:GetVertexColor())
	self:UnregisterEvent("PLAYER_TARGET_CHANGED")
end
This worked and gave me 0 lua error.

But i have to have the onLoad script to make it work!

"self:RegisterEvent("PLAYER_TARGET_CHANGED")"

And then the lua provided in "onEvent".

The first target doesn't give me the right color, it's just white, but the second and later gives me the correct color.

But atleast now my first target doesn't give me a lua error :P
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » KGpanels target color script help!

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