Thread Tools Display Modes
03-06-10, 09:38 AM   #1
Thalyra
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 13
changing hotkey color

hello,

i made a script to change the hotkey color of my bartender buttons

the script is in kgpanels with "OnLoad", it works when i click on "Accept" in the KgPanels configuration menu, but when i reload my UI or relog, it doesnt work

the script (shortened):

class = UnitClass("player")
local r,g,b = 0,0,0

if class == "Krieger" or class == "Kriegerin" or class == "Warrior" then
r,g,b = 0.78,0.61,0.43
elseif class == "Priester" or class == "Priesterin" or class == "Priest" then
r,g,b = 1,1,1
.... (other classes)
end

BT4Button1.hotkey:SetVertexColor(r,g,b,1)
BT4Button2.hotkey:SetVertexColor(r,g,b,1)
.... (other buttons)
BT4Button70.hotkey:SetVertexColor(r,g,b,1)
BT4Button71.hotkey:SetVertexColor(r,g,b,1)
does anyone know how i can fix this script, so it works on UI reload etc?

Thalyra
  Reply With Quote
03-06-10, 09:42 AM   #2
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Open up the kgPanels folder, and just append the code that you have to any .lua file.
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
03-06-10, 10:05 AM   #3
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Not related to your question but constants.lua has

Code:
RAID_CLASS_COLORS = {
	["HUNTER"] = { r = 0.67, g = 0.83, b = 0.45 },
	["WARLOCK"] = { r = 0.58, g = 0.51, b = 0.79 },
	["PRIEST"] = { r = 1.0, g = 1.0, b = 1.0 },
	["PALADIN"] = { r = 0.96, g = 0.55, b = 0.73 },
	["MAGE"] = { r = 0.41, g = 0.8, b = 0.94 },
	["ROGUE"] = { r = 1.0, g = 0.96, b = 0.41 },
	["DRUID"] = { r = 1.0, g = 0.49, b = 0.04 },
	["SHAMAN"] = { r = 0.0, g = 0.44, b = 0.87 },
	["WARRIOR"] = { r = 0.78, g = 0.61, b = 0.43 },
	["DEATHKNIGHT"] = { r = 0.77, g = 0.12 , b = 0.23 },
}
defined as a global variable and the second return value of UnitClass() is exactly the value you need for this.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
03-06-10, 10:09 AM   #4
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Originally Posted by Rilgamon View Post
Not related to your question but constants.lua has

Code:
RAID_CLASS_COLORS = {
	["HUNTER"] = { r = 0.67, g = 0.83, b = 0.45 },
	["WARLOCK"] = { r = 0.58, g = 0.51, b = 0.79 },
	["PRIEST"] = { r = 1.0, g = 1.0, b = 1.0 },
	["PALADIN"] = { r = 0.96, g = 0.55, b = 0.73 },
	["MAGE"] = { r = 0.41, g = 0.8, b = 0.94 },
	["ROGUE"] = { r = 1.0, g = 0.96, b = 0.41 },
	["DRUID"] = { r = 1.0, g = 0.49, b = 0.04 },
	["SHAMAN"] = { r = 0.0, g = 0.44, b = 0.87 },
	["WARRIOR"] = { r = 0.78, g = 0.61, b = 0.43 },
	["DEATHKNIGHT"] = { r = 0.77, g = 0.12 , b = 0.23 },
}
defined as a global variable and the second return value of UnitClass() is exactly the value you need for this.
So, in case you don't know how to get the second return value of UnitClass(), use this:

Code:
_, class = UnitClass()
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
03-06-10, 10:19 AM   #5
Thalyra
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 13
thank you very much for the hint with the second value, but i tried what you said and BaudErrorFrame gives me this error:

Interface\AddOns\kgPanels\kgPanels.lua:1007: attempt to index global 'BT4Button1' (a nil value)
Count: 1

Call Stack:
[C]: ?
Interface\AddOns\kgPanels\kgPanels.lua:1007: in main chunk
Thalyra
  Reply With Quote
03-06-10, 12:19 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Your script is trying to run before BT4 is finished loading. This is why it works when clicking "Accept", but not when logging in or reloading. There is a Dependencies section for your kgPanels script. Put Bartender4 in there.
__________________
"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
03-06-10, 12:25 PM   #7
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Add this line to kgPanels.toc:

Code:
##OptionalDeps: Bartender4
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
03-06-10, 12:28 PM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
As I said, there is a Dependencies section right in the kgPanels scripts section. You don't need to go mucking around in another addon's .toc file.
__________________
"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
03-06-10, 12:39 PM   #9
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Originally Posted by Seerah View Post
As I said, there is a Dependencies section right in the kgPanels scripts section. You don't need to go mucking around in another addon's .toc file.
Oh K, I thought you meant this, so I explained it.
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
03-06-10, 01:32 PM   #10
Thalyra
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 13
hello,

thank you very much for your help, the part with the dependencies works

but when i switch stances for example, the color switches back

i editet ActionButton.lua with following code:

_, class = UnitClass("player")

local cc = {}

if class == "WARRIOR" then
cc = { r = 0.78, g = 0.61, b = 0.43 }
elseif class == "PRIEST" then
cc = { r = 1.0, g = 1.0, b = 1.0 }
...(other classes)
end
and changed every

.hotkey:SetVertexColor(1.0, 1.0, 1.0)
to

.hotkey:SetVertexColor(cc.r, cc.g, cc.b)
Bartender4.Button:Create now has this line of code, too

this solution works, but a script in kgpanels would be a better solution, i think

Thalyra

Thalyra
  Reply With Quote
03-06-10, 11:08 PM   #11
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
There are a total of 120 buttons. Did you only account for 71 of them?
__________________
"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
03-07-10, 04:21 AM   #12
Thalyra
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 13
no, with the changes of bartender, all colors are changed

with the script i only wanted 11 buttons of bar 1 and bar 6, because they are the only one with hotkeys

Thalyra
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » changing hotkey color

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