Home › Forums › General › Programming › Making a panel appearance alter depending on list selection
- This topic has 9 replies, 2 voices, and was last updated 11 years, 11 months ago by atom.
-
AuthorPosts
-
May 2, 2012 at 11:20 pm #603
Hello,
Please help with my LUA. I’m very new to it, so there will be loads of things I have wrong.
Basically I have a list of effects in a drop down list (Pedals) and I want change the visibility of some controllers and rename the legend in others to make the knobs make sense in context of what is chosen in the list.
I have tried to copy the syntax in Virus TI Snow VC method OSC2_mode called up in OSC2 Mode controller.
I’m running the Nightly version of CTRLR and I get an LUA runtime error when the PanelList method is called up.
I have attached my panel in its latest form
please help me!!!
May 4, 2012 at 1:14 pm #4275If you want to fetch a Component object using
[code:3gxdlo6n]
getcomponentByName("PedalDrive")
[/code:3gxdlo6n]
you need to execute this method on the panel like so:
[code:3gxdlo6n]
pedalDrive = panel:getcomponentByName("PedalDrive")
[/code:3gxdlo6n]and now the pedalDrive variable is the Component object you can modify and set it’s properties
May 4, 2012 at 9:20 pm #4276Hi Atom,
Thanks for the reply. I’m still missing a trick some where.
I tried this code:
[code:2izc5qiy]Panellist = function (modulator,newvalue)panel:getModulatorByName("PedalList")
PedalNo = getmodulatorvalue()
if PedalNo > 15 then PedalNo = 15 end
if PedalNo < 0 then PedalNo = 0 endif PedalNo == 0 then
PedalDrive = Panel:getComponentbyname("PedalDrive")
setComponentText ("componentVisibleName" , "Sens")
setPropertyString ("componentVisibility" , "1")
PedalLevel = Panel:getComponentbyname("PedalLevel")
setComponentText ("componentVisibleName" , "Drive")
setPropertyString ("componentVisibility" , "1")
PedalTone = Panel:getComponentbyname("PedalTone")
setComponentText ("componentVisibleName" , "Off")
setPropertyString ("componentVisibility" , "0")
PedalManual = Panel:getComponentbyname("PedalManual")
setComponentText ("componentVisibleName" , "Off")
setPropertyString ("componentVisibility" , "0")
PedalType = Panel:getComponentbyname("PedalType")
setComponentText ("componentVisibleName" , "Off")
setPropertyString ("componentVisibility" , "0")end
end[/code:2izc5qiy]
I just get a ‘Callback error’ Lua runtime error
Am I getting any closer? Once I can crack this, I’ll copy the syntax for the other FX drop downs. Would you recommend individual methods for each drop down, or one long method.. Does it matter?
Thanks for looking at this so far.
Cheers
May 4, 2012 at 11:14 pm #4277You’re not getting it, i said to get the object and set it’s properties:
[code:38vkcm4p]
— You fetch the object by it’s name
PedalLevel = Panel:getComponentbyname("PedalLevel")— Check if you got the object and it’s valid, if it’s invalid, calling anything on it will cause a crash
if PedalLevel ~= nil then
— the object is fine we can set it’s properties and do what we want with it
PedalLevel:setComponentText ("componentVisibleName" , "Drive")
PedalLevel:setPropertyString ("componentVisibility" , "1")
end
[/code:38vkcm4p]hope you get it now, it’s all objective programming in a way think of "PedalLevel" as an object and any variable as an object you set/get properties on it, they live in the "panel" object.
May 5, 2012 at 10:27 pm #4278SO now I think I have the syntax right for setting the controller’s visibility and name legend. How do I set about making the correct set of values depending on the selection in ‘PedalList’ which is a drop down list with 15 entries
SO I want to check the modulator value in pedallist drop down and set the values for the other controllers in the same group accordingly. eg if pedal 0 is selected in pedal list then only 2 knobs appear labelled ‘Sens’ and ‘Level’ if pedal 1 is selected then 3 knobs appear labelled ‘Drive’, ‘Level’ and ‘Tone’
SO I get the object (Panellist) and check its value, then us if/then to set the other knob props
Here’s my code!
[code:jm7id1w4]–
— Called when a modulator value changes
—panel:getModulatorByName("PedalList")
if PedalList~=nil then
PedalListNo = panel:getModulatorValue("PedalList")
end
if
PedalListNo == 0 thenPedalDrive = panel : getComponentbyname("PedalDrive")
if PedalDrive~= nil then
PedalDrive : setComponentText ("componentVisibleName" , "Sens")
PedalDrive : setPropertyString ("componentVisibility" , "1")
end
PedalLevel = panel : getComponentbyname("PedalLevel")
if PedalLevel~= nil then
PedalLevel : setComponentText ("componentVisibleName" , "Drive")
PedalLevel : setPropertyString ("componentVisibility" , "1")
end
PedalTone = Panel : getComponentbyname("PedalTone")
if PedalTone~= nil then
PedalTone : setComponentText ("componentVisibleName" , "Off")
PedalTone : setPropertyString ("componentVisibility" , "0")
end
PedalManual = panel : getComponentbyname("PedalManual")
if PedalManual~= nil then
PedalTone : setComponentText ("componentVisibleName" , "Off")
PedalTone : setPropertyString ("componentVisibility" , "0")
end
PedalType = panel : getComponentbyname("PedalType")
if PedalType~= nil then
PedalType : setComponentText ("componentVisibleName" , "Off")
PedalType : setPropertyString ("componentVisibility" , "0")
endend
if
PedalListNo == 1 thenPedalDrive = panel : getComponentbyname("PedalDrive")
if PedalDrive~= nil then
PedalDrive : setComponentText ("componentVisibleName" , "Drive")
PedalDrive : setPropertyString ("componentVisibility" , "1")
end
PedalLevel = panel : getComponentbyname("PedalLevel")
if PedalLevel~= nil then
PedalLevel : setComponentText ("componentVisibleName" , "Level")
PedalLevel : setPropertyString ("componentVisibility" , "1")
end
PedalTone = Panel : getComponentbyname("PedalTone")
if PedalTone~= nil then
PedalTone : setComponentText ("componentVisibleName" , "Tone")
PedalTone : setPropertyString ("componentVisibility" , "1")
end
PedalManual = panel : getComponentbyname("PedalManual")
if PedalManual~= nil then
PedalTone : setComponentText ("componentVisibleName" , "Off")
PedalTone : setPropertyString ("componentVisibility" , "0")
end
PedalType = panel : getComponentbyname("PedalType")
if PedalType~= nil then
PedalType : setComponentText ("componentVisibleName" , "Off")
PedalType : setPropertyString ("componentVisibility" , "0")
endend
— this will be repeated for all 15 pedals each with different names/visibility
[/code:jm7id1w4]Sorry if I’m being hard work!! :-s I really would like to understand it properly and make more panels.
Thanks in advance!
May 5, 2012 at 11:59 pm #4279Well allright i get what you want, how is that code working for you ? It’s not working at all it’s working just a little? What’s wrong ?
May 7, 2012 at 3:46 pm #4280OK, a few things I tried.
Firstly I had the word ‘panel’ as part of my method name. I changed the method name to not include the word ‘panel’ and at least now instead of a run time error, I get syntax errors with line numbers etc which helps debug.
I have fixed the ‘check which pedal was chosen’ code. I can tell because any errors come from a line number in the appropriate ‘if’ sub-routine for the pedal selected. ” title=”Very Happy” />
Each of the pedal subroutines are the same as the code below, but with different componentVisibleNames and componentVisibilty
[code:2fj75dom]if Choice == 0 then
–compressor pedal MXR Super Comp
PedalDrive=panel:getModulatorByName("PedalDrive")
PedalDrive:setComponentText(componentVisibleName,"Sens")
PedalDrive:setPropertyString("componentVisibility","1")
PedalLevel=panel:getModulatorByName("PedalLevel")
PedalLevel:setComponentText ("componentVisibleName","Level")
PedalLevel:setPropertyString ("componentVisibility","1")
PedalTone=panel:getModulatorByName("PedalTone")
PedalTone:setComponentText ("componentVisibleName","—")
PedalTone:setPropertyString ("componentVisibility","0")
PedalManual = panel:getModulatorByName("PedalManual")
PedalManual:setComponentText ("componentVisibleName","—")
PedalManual:setPropertyString ("componentVisibility","0")
PedalType = panel : getModulatorByName("PedalType")
PedalType:setComponentText ("componentVisibleName","—")
PedalType:setPropertyString ("componentVisibility","0")[/code:2fj75dom]When I select a pedel, I get an error refering to this line of code:
PedalDrive:setComponentText(componentVisibleName,"Sens")
The error is:
Error message:
[string "…"]:30: attempt to call method ‘setComponentText’ (a nil value). Method disabledIf I swap the order of the setComponentText line with the setPropertyString line then I still get the same error referring to the setComponentText. Even though no error was found for the setPropertyString line, the knob does not go invisible. (I checked by setting the visibility to 0 although in the code above it is set to 1 which would be the intended setting.)
I hope this is clear! ” title=”Confused” />
Cheers
May 7, 2012 at 6:25 pm #4281I’ll give you a quick hint. Since you don’t get LUA and that’s ok try to use uiTabs for that, that will work without any LUA code, just create some tabs, drag them sliders in there and that’s it. Faster and easier to operate.
May 12, 2012 at 10:32 pm #4282Well, I finally sussed it!
I ended up writing it all out long hand here is an example of the code I used
[code:24ym0bbv]if newValue < 0 then Choice = 0 end
if newValue > 10 then Choice = 10 end–Settings for pedals 1-10
if Choice == 0 then
–Maestro Echoplex
panel:getModulatorByName("DelayTime"):getComponent():setPropertyInt("componentVisibility",1)
panel:getModulatorByName("DelayTime"):getComponent():setPropertyString("componentVisibleName","Time")
panel:getModulatorByName("DelayFeedback"):getComponent():setPropertyInt("componentVisibility",1)
panel:getModulatorByName("DelayFeedback"):getComponent():setPropertyString("componentVisibleName","Feedback")
panel:getModulatorByName("DelayTone"):getComponent():setPropertyInt("componentVisibility",1)
panel:getModulatorByName("DelayTone"):getComponent():setPropertyString("componentVisibleName","Tone")
panel:getModulatorByName("DelayDucking"):getComponent():setPropertyInt("componentVisibility",0)
panel:getModulatorByName("DelayDucking"):getComponent():setPropertyString("componentVisibleName","—")
panel:getModulatorByName("DelayOption"):getComponent():setPropertyInt("componentVisibility",1)
panel:getModulatorByName("DelayOption"):getComponent():setPropertyString("componentVisibleName","Lo Damp")
panel:getModulatorByName("DelayMix"):getComponent():setPropertyInt("componentVisibility",1)
panel:getModulatorByName("DelayMix"):getComponent():setPropertyString("componentVisibleName","Mix")end
[/code:24ym0bbv]
A different set of Visibility and names settings for each different value of choice
I think I’m getting there, but there are a couple more things I want to do to get the panel finished…..!
I’ll keep plugging away.
May 12, 2012 at 11:50 pm #4283Well it’s simple once you get the hang of it. Keep asking those questions i’ll answer and help as much as i can.
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.