Im trying to change the colour of a texture using the Color picker frame
This is my current slash command I'd like to replace with the color picker
Code:
-- Slash command to change color
SLASH_COLORCHANGE1 = "/starcolour"
SlashCmdList["COLORCHANGE"] = function(msg)
local r, g, b = strsplit(" ", msg)
r, g, b = tonumber(r), tonumber(g), tonumber(b)
if r and g and b then
local alpha = StarCursor.texture:GetAlpha()
StarCursor.texture:SetVertexColor(r, g, b, alpha)
StarCursorSettings.r, StarCursorSettings.g, StarCursorSettings.b = r, g, b
end
end
Code:
-- Slash command to open color picker
SLASH_COLORPICKER1 = "/starcolour"
SlashCmdList["COLORPICKER"] = function()
ColorPickerFrame:SetupColorPickerAndShow({
r = StarCursorSettings.r,
g = StarCursorSettings.g,
b = StarCursorSettings.b,
opacity = StarCursorSettings.alpha,
hasOpacity = true,
swatchFunc = function()
local r, g, b = ColorPickerFrame:GetColorRGB()
StarCursor.texture:SetVertexColor(r, g, b, a)
StarCursorSettings.r, StarCursorSettings.g, StarCursorSettings.b, StarCursorSettings.alpha = r, g, b, a
end,
cancelFunc = function()
-- Do nothing on cancel
end
})
end
If I change the color on the wheel and then cancel, it doesnt revert the color it just stays how it was selected on the wheel.