WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   changing hotkey color (https://www.wowinterface.com/forums/showthread.php?t=31098)

Thalyra 03-06-10 09:38 AM

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

Quote:

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

nightcracker 03-06-10 09:42 AM

Open up the kgPanels folder, and just append the code that you have to any .lua file.

Rilgamon 03-06-10 10:05 AM

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.

nightcracker 03-06-10 10:09 AM

Quote:

Originally Posted by Rilgamon (Post 180762)
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()

Thalyra 03-06-10 10:19 AM

thank you very much for the hint with the second value, but i tried what you said and BaudErrorFrame gives me this error:

Quote:

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

Seerah 03-06-10 12:19 PM

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.

nightcracker 03-06-10 12:25 PM

Add this line to kgPanels.toc:

Code:

##OptionalDeps: Bartender4

Seerah 03-06-10 12:28 PM

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.

nightcracker 03-06-10 12:39 PM

Quote:

Originally Posted by Seerah (Post 180778)
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.

Thalyra 03-06-10 01:32 PM

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:

Quote:

_, 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

Quote:

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

Quote:

.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

Seerah 03-06-10 11:08 PM

There are a total of 120 buttons. Did you only account for 71 of them?

Thalyra 03-07-10 04:21 AM

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


All times are GMT -6. The time now is 08:13 PM.

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