Go to Page... |
Thread Tools | Display Modes |
02-06-23, 03:14 AM | #1 |
How to move my slash commands to the options panel?
So my brain hurts from trying to figure this out. I tried to look at some of the other addons that I have installed, but they all seem to use libraries for this, which I don't use or really understand.
So I currently use a set of slash commands to handle the only configurable portion of my addon, the color in which the text is displayed for the user. Currently this is how I accomplish this: Lua Code:
I figured the first thing I would try to get working is adding a button to the options panel, which when you click on it, it calls my already defined color picker functions. Lua Code:
This successfully adds a new panel to the ingame options window with the desired title displayed and the clickable button. However, when I actually click on the button, it throws an error: Code:
5x ConvertRatings/ConvertRatings.lua:27: bad argument #1 to 'SetColorRGB' (Usage: self:SetColorRGB(rgb)) [string "=[C]"]: in function `SetColorRGB' [string "@ConvertRatings/ConvertRatings.lua"]:27: in function <ConvertRatings/ConvertRatings.lua:26> Locals: (*temporary) = ColorPickerFrame { 0 = <userdata> Center = Texture { } PixelSnapDisabled = true TopLeftCorner = Texture { } OnBackdropLoaded = <function> defined @SharedXML/Backdrop.lua:152 Border = Frame { } BottomEdge = Texture { } GetBackdropColor = <function> defined @SharedXML/Backdrop.lua:390 SetupTextureCoordinates = <function> defined @SharedXML/Backdrop.lua:214 OnBackdropSizeChanged = <function> defined @SharedXML/Backdrop.lua:182 HasBackdropInfo = <function> defined @SharedXML/Backdrop.lua:278 SetBackdropBorderColor = <function> defined @SharedXML/Backdrop.lua:422 RightEdge = Texture { } BottomRightCorner = Texture { } BottomLeftCorner = Texture { } GetEdgeSize = <function> defined @SharedXML/Backdrop.lua:188 template = "Transparent" TopRightCorner = Texture { } TopEdge = Texture { } ApplyBackdrop = <function> defined @SharedXML/Backdrop.lua:294 SetBackdrop = <function> defined @SharedXML/Backdrop.lua:329 ClearBackdrop = <function> defined @SharedXML/Backdrop.lua:282 backdropInfo = <table> { } GetBackdropBorderColor = <function> defined @SharedXML/Backdrop.lua:409 GetBackdrop = <function> defined @SharedXML/Backdrop.lua:347 SetBorderBlendMode = <function> defined @SharedXML/Backdrop.lua:266 SetupPieceVisuals = <function> defined @SharedXML/Backdrop.lua:246 SetBackdropColor = <function> defined @SharedXML/Backdrop.lua:399 LeftEdge = Texture { } Header = Frame { } } (*temporary) = Button { SetTextToFit = <function> defined @SharedXML/SecureUIPanelTemplates.lua:440 Right = Texture { } Left = Texture { } fitTextWidthPadding = 40 FitToText = <function> defined @SharedXML/SecureUIPanelTemplates.lua:445 Text = TopText { } 0 = <userdata> Middle = Texture { } fitTextCanWidthDecrease = true } (*temporary) = "LeftButton" (*temporary) = false Lua Code:
but that just throws a different error when you load in: Code:
2x ConvertRatings/ConvertRatings.lua:79: Usage: Button:HookScript("frameScriptTypeName", function[, bindingType]) [string "=[C]"]: in function `HookScript' [string "@ConvertRatings/ConvertRatings.lua"]:79: in main chunk Locals: (*temporary) = Button { SetTextToFit = <function> defined @SharedXML/SecureUIPanelTemplates.lua:440 Right = Texture { } Left = Texture { } fitTextWidthPadding = 40 FitToText = <function> defined @SharedXML/SecureUIPanelTemplates.lua:445 Text = TopText { } 0 = <userdata> Middle = Texture { } fitTextCanWidthDecrease = true } (*temporary) = "OnClick" What probably glaring issue am I not seeing here? Why does changing it from a slash command to a button press fuck it all up? |
|
![]() |
02-06-23, 07:39 AM | #2 |
Code:
cvrbutton:HookScript("OnClick", function() ShowColorPicker(cvred, cvgreen, cvblue, nil, myColorCallback) end)
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 02-06-23 at 07:58 AM. |
|
![]() |
02-06-23, 01:50 PM | #3 | |
Wrapping ShowColorPicker in function() and end seemed to do the trick as the color picker now shows and sets the color when you pick one. |
||
![]() |
02-06-23, 03:29 PM | #4 |
Ok so I have one final problem that I can't seem to figure out, and my googling has turned up no help.
In addition to the color wheel, I have some hard coded color options that I want the user to be able to choose from via a drop down menu. I was able to successfully get the drop down to successfully open, set the colors in my addon and then display the current color chosen in the drop down frame when it is closed. My saved variables get set properly so the color is saved between sessions. What I can't figure out is how to get the drop down menu to read from the saved variables so that it will correctly display the chosen value when the user opens up the options menu in a different session. When I reload the ui, it sets the value of the displayed text to "Default". I tried to not declare a default value for cvcolor at the top of the file, but then i get a nil value concat error. cvred, cvgreen, cvblue, cvalpha, cvcolor are all declared in my toc and I can watch the saved variables file get updated when i reload the ui. Again I'm probably missing something stupid easy. Lua Code:
Edit: I just noticed that when I click on the dropdown menu in the options frame, the displayed text changes to the value currently set in the saved variable. So it knows what it is between sessions, it just doesn't update until i click on the drop down menu frame. Last edited by briskman3000 : 02-06-23 at 03:39 PM. |
|
![]() |
02-06-23, 03:45 PM | #5 |
I figured it out.
I had to add the UIDropDownMenu_SetText fucntion to my addon's hook to the PLAYER_ENTERING_WORLD event. Now when I open up the options frame in a different session, it correctly displays the value set in the saved variable in the drop down menu. |
|
![]() |
WoWInterface » Developer Discussions » Lua/XML Help » How to move my slash commands to the options panel? |
«
Previous Thread
|
Next Thread
»
|
Thread Tools | |
Display Modes | |
|
|