Lua Help

Home Forums General Programming Lua Help

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #375
    netchose
    Participant
      • Topics: 15
      • Replies: 70
      • Total: 85

      i have changed the color example.

      i have use the CtrlrLuaObject ( "A class that defines standard access methods for all Ctrlr-LUA based objects like Panels, Modulators, Components, MidiMessages etc")
      – try to change postion and size , nothing happened
      – try to change modulator value, nothing happened

      is there an error in the code?

      thanks

      [code:jox4qiq7]randomSliderColour = function(modulator, newValue)
      n = panel:getNumModulators()

      for idx = 0, n-1 do
      m = panel:getModulatorByIndex(idx)

      if m ~= nil then
      c = m:getComponent()
      if c ~= nil then
      if c:getPropertyString("uiType") == "uiSlider" then
      c:setPropertyString("componentRectangle","217 30 32 191")
      m:setPropertyInt("modulatorValue",25)
      end
      end
      end
      end
      end[/code:jox4qiq7]

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

        yes i forgot to document the most important method i’m afraid, to change values for a modulator there is a special method setModulatorValue() this is because it’s a bit more compilcated, for example to set some random values to sliders on the panel (from 0-124) use this code
        [code:14yn2wyz]
        randomSliderColour = function(modulator, newValue)
        n = panel:getNumModulators()

        for idx = 0, n-1 do

        m = panel:getModulatorByIndex(idx)

        if m ~= nil then
        c = m:getComponent()

        if c:getPropertyString("uiType") == "uiSlider" then
        m:setModulatorValue (utils.randomInt(124), false, false, true)
        end
        end

        end
        end
        [/code:14yn2wyz]

        this line-> m:setModulatorValue (utils.randomInt(124), false, false, true) means set the random value (max 124), the bool params tell the modulator witch subsystems to notify about the change, this will be in the docs

        [code:14yn2wyz]
        void setModulatorValue(const int newValue, const bool notifyVstHost=false, const bool notifyMidiDevice=false, const bool notifyComponent=false);
        [/code:14yn2wyz]

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

          also this code changes the position of the first slider:
          [code:1f9xrow8]

          — Called when a modulator value changes

          randomSliderColour = function(modulator, newValue)
          m = panel:getModulatorByName("modulator-1")

          if m ~= nil then
          c = m:getComponent()
          c:setPropertyString ("componentRectangle", "128 128 64 64")
          end
          end
          [/code:1f9xrow8]

          so i guess this should work

          #2921
          netchose
          Participant
            • Topics: 15
            • Replies: 70
            • Total: 85

            it’s ok.

            an other question :

            is there a way to access to the current modulator.
            something like : this:getcomponent()

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

              yest and no, in the methods for a modulator the first parameter to the function is the modulator and the 2nd is the new value
              so yes
              modulator:getComponent() will work in that call, it won’t in the panel call since its triggered in the panel context.

              #2923
              netchose
              Participant
                • Topics: 15
                • Replies: 70
                • Total: 85

                if i link several modulators to an other one modulator , so the current modulator value is equal to the value of this modalor.
                it can be a way
                since i have made the test, the change of modulator link is made before the lua script

              Viewing 6 posts - 1 through 6 (of 6 total)
              • The forum ‘Programming’ is closed to new topics and replies.
              There is currently 0 users and 60 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