Making a panel appearance alter depending on list selection

Home Forums General Programming Making a panel appearance alter depending on list selection

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #603
    moroccomoose
    Participant
      • Topics: 5
      • Replies: 6
      • Total: 11

      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!!!

      #4275
      atom
      Keymaster
        • Topics: 159
        • Replies: 2945
        • Total: 3104
        • ★★★★★

        If 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

        #4276
        moroccomoose
        Participant
          • Topics: 5
          • Replies: 6
          • Total: 11

          Hi 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 end

          if 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

          #4277
          atom
          Keymaster
            • Topics: 159
            • Replies: 2945
            • Total: 3104
            • ★★★★★

            You’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.

            #4278
            moroccomoose
            Participant
              • Topics: 5
              • Replies: 6
              • Total: 11

              SO 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 then

              PedalDrive = 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")
              end

              end

              if
              PedalListNo == 1 then

              PedalDrive = 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")
              end

              end

              — 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!

              #4279
              atom
              Keymaster
                • Topics: 159
                • Replies: 2945
                • Total: 3104
                • ★★★★★

                Well 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 ?

                #4280
                moroccomoose
                Participant
                  • Topics: 5
                  • Replies: 6
                  • Total: 11

                  OK, 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. <img decoding=” 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 disabled

                  If 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! <img decoding=” title=”Confused” />

                  Cheers

                  #4281
                  atom
                  Keymaster
                    • Topics: 159
                    • Replies: 2945
                    • Total: 3104
                    • ★★★★★

                    I’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.

                    #4282
                    moroccomoose
                    Participant
                      • Topics: 5
                      • Replies: 6
                      • Total: 11

                      Well, 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.

                      #4283
                      atom
                      Keymaster
                        • Topics: 159
                        • Replies: 2945
                        • Total: 3104
                        • ★★★★★

                        Well it’s simple once you get the hang of it. Keep asking those questions i’ll answer and help as much as i can.

                      Viewing 10 posts - 1 through 10 (of 10 total)
                      • The forum ‘Programming’ is closed to new topics and replies.
                      There is currently 0 users and 45 guests online
                      No users are currently active
                      Forum Statistics
                      Threads: 2,495, Posts: 17,374, Members: 77,605
                      Most users ever online was 12 on January 22, 2019 3:47 pm
                      Ctrlr