Carbonite Maps

Carbonite Maps

6M Downloads

bad argument #5 to '?' (Usage: self:SetVertexColor(color [, a]))

Thrumbar opened this issue ยท 4 comments

commented

click menu then tracking HUD to get the error. This is on ptr 10.1

Message: bad argument #5 to '?' (Usage: self:SetVertexColor(color [, a]))
Time: Thu Apr 6 11:13:09 2023
Count: 1
Stack: bad argument #5 to '?' (Usage: self:SetVertexColor(color [, a]))
[string "=[C]"]: in function SetVertexColor' [string "@Interface/AddOns/Carbonite/Libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua"]:105: in function SetColor'
[string "@Interface/AddOns/Carbonite/Libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua"]:1377: in function <...nfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua:1110>
[string "@Interface/AddOns/Carbonite/Libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua"]:1639: in function FeedGroup' [string "@Interface/AddOns/Carbonite/Libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua"]:1919: in function Open'
[string "@Interface/AddOns/Carbonite/Libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua"]:1947: in function <...nfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua:1945>
[string "=[C]"]: ?
[string "@Interface/AddOns/Carbonite/Libs/AceGUI-3.0/AceGUI-3.0.lua"]:66: in function <...face/AddOns/Carbonite/Libs/AceGUI-3.0/AceGUI-3.0.lua:64>
[string "@Interface/AddOns/Carbonite/Libs/AceGUI-3.0/AceGUI-3.0.lua"]:300: in function Fire' [string "@Interface/AddOns/Carbonite/Libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua"]:20: in function <...GUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua:19> [string "=[C]"]: in function Show'
[string "@Interface/SharedXML/Settings/Blizzard_SettingsPanel.lua"]:846: in function DisplayLayout' [string "@Interface/SharedXML/Settings/Blizzard_SettingsPanel.lua"]:805: in function DisplayCategory'
[string "@Interface/SharedXML/Settings/Blizzard_SettingsPanel.lua"]:772: in function <...erface/SharedXML/Settings/Blizzard_SettingsPanel.lua:768>
[string "=[C]"]: ?
[string "@Interface/SharedXML/CallbackRegistry.lua"]:178: in function <Interface/SharedXML/CallbackRegistry.lua:177>
[string "=[C]"]: ?
[string "@Interface/SharedXML/CallbackRegistry.lua"]:181: in function `TriggerEvent'
[string "@Interface/SharedXML/Settings/Blizzard_CategoryList.lua"]:136: in function <...terface/SharedXML/Settings/Blizzard_CategoryList.lua:134>

Locals:

commented

Is this still a problem on Retail?

commented

Yes it is still occurring.

commented

The SetColor function, as it's defined, expects four arguments:

lua

["SetColor"] = function(self, r, g, b, a)
self.r = r
self.g = g
self.b = b
self.a = a or 1
self.colorSwatch:SetVertexColor(r, g, b, a)
end,

From your error message, it seems like a fifth argument is somehow being passed to this function. A potential problematic point in your code is the ColorCallback function:

lua

local function ColorCallback(self, r, g, b, a, isAlpha)
if not self.HasAlpha then
a = 1
end
self:SetColor(r, g, b, a)
-- rest of the function
end

Here, a fifth argument isAlpha is passed to the SetColor function, when it only expects four. If isAlpha is not nil or false, then SetColor will interpret it as an additional argument and produce the error you're seeing.

A solution could be to update your SetColor function to handle this fifth isAlpha argument, even if it doesn't use it:

lua

["SetColor"] = function(self, r, g, b, a, isAlpha)
self.r = r
self.g = g
self.b = b
self.a = a or 1
self.colorSwatch:SetVertexColor(r, g, b, a)
end,

Alternatively, you could modify ColorCallback to not pass isAlpha to SetColor:

lua

local function ColorCallback(self, r, g, b, a, isAlpha)
if not self.HasAlpha then
a = 1
end
self:SetColor(r, g, b, a)
-- rest of the function
end

I'd recommend the first solution as it seems more robust. This way, even if other parts of your code call SetColor with an additional argument, your program won't break.

commented

Ok, should be fixed now ;)