Issue with getModulatorValue

Home Forums General Programming Issue with getModulatorValue

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #71398
    dashie
    Participant
    • Topics: 1
    • Replies: 4
    • Total: 5

    Hello,

    I’m using a function via “Called when the modulator value changes” to send an appropriate Prg change when using some switchs and have an issue with the lua code.

    I have three groups of 6, 3 and 3 uiToggleButton, each with a different name and each in a Radio group of 1, 2 and 3 respectively (with Is component a member of a group checked”.
    This part is OK, I can have only one button checked at a time in one of each groups.

    In the Modulator list window I can correctly see all buttons with modulatorValue of 0 excepted the one checked in each group.

    I then use “Panel> Panel mode” to try my code.

    My code is as following and the issue is that I got:

    tRoom 1 tHall 1 tChamber 1 tPlate 1 tCathedral 1 tGated 1
    sSmall 1 sMedium 1 sLarge 1
    cDark 1 cMed 1 cBright 1
    selected prg 1

    In the console. Where I should got something like (shorted for visibility) 100000, 100 and 100 (or any other place for the 1 depending on the “default” one).

    I can check any switch I always got the same return of “1” from getModulatorValue

    Any ideas what can be wrong ?

    (Ctrlr 5.4.29 on win10 from website build)

    Code:

    selectionChanged = function(value)
      tRoom = panel:getModulatorByName("typeRoom"):getModulatorValue()
      tHall = panel:getModulatorByName("typeHall"):getModulatorValue()
      tChamber = panel:getModulatorByName("typeChamber"):getModulatorValue()
      tPlate = panel:getModulatorByName("typePlate"):getModulatorValue()
      tCathedral = panel:getModulatorByName("typeCathedral"):getModulatorValue()
      tGated = panel:getModulatorByName("typeGated"):getModulatorValue()
      
      sSmall = panel:getModulatorByName("sizeSmall"):getModulatorValue()
      sMedium = panel:getModulatorByName("sizeMedium"):getModulatorValue()
      sLarge = panel:getModulatorByName("sizeLarge"):getModulatorValue()
    
      cDark = panel:getModulatorByName("colorDark"):getModulatorValue()
      cMed = panel:getModulatorByName("colorMed"):getModulatorValue()
      cBright = panel:getModulatorByName("colorBright"):getModulatorValue()
    
      console("tRoom " .. tRoom .. " tHall " .. tHall .. " tChamber " .. tChamber .. " tPlate " .. tPlate .. " tCathedral " .. tCathedral .. " tGated " .. tGated)
      console("sSmall " .. sSmall .. " sMedium " .. sMedium .. " sLarge " .. sLarge)
      console("cDark " .. cDark .. " cMed " .. cMed .. " cBright " .. cBright)
    
      prg = 0
    
      if tRoom == 1 and sSmall == 1 and cDark == 1 then
        prg = 1
      elseif tRoom == 1 and sSmall == 1 and cMed == 1 then
        prg = 2
      elseif tRoom == 1 and sSmall == 1 and cBright == 1 then
        prg = 3
      elseif tRoom == 1 and sMed == 1 and cDark == 1 then
        prg = 4
      elseif tRoom == 1 and sMed == 1 and cMed == 1 then
        prg = 5
      elseif tRoom == 1 and sMed == 1 and cBright == 1 then
        prg = 6
      elseif tRoom == 1 and sLarge == 1 and cDark == 1 then
        prg = 7
      elseif tRoom == 1 and sLarge == 1 and cMed == 1 then
        prg = 8
      elseif tRoom == 1 and sLarge == 1 and cBright == 1 then
        prg = 9
    ... snip 5 others blocks like this one for every other switches ...
    ... blah blah blah ...
      elseif tGated == 1 and sLarge == 1 and cBright == 1 then
        prg = 54
    
      else
        prg = 127
        console("This isnt right, bug somewhere")
        return Null
      end
    
      console("selected prg " .. prg)
    end
    #71399
    goodweather
    Participant
    • Topics: 45
    • Replies: 550
    • Total: 595
    • ★★★

    Without looking further, I would advise you to reduce the size of this problem…
    In a new panel, create 2 uiToggleButton (I’m using uiImageButton – not sure it is the same but it works fine for On/Off things).

    In the console check you get the correct value:

    console(tostring(panel:getModulatorByName("typeRoom"):getModulatorValue()))
    console(tostring(panel:getModulatorByName("typeHall"):getModulatorValue()))

    Then group them as radio button and do the same check.

    #71401
    dashie
    Participant
    • Topics: 1
    • Replies: 4
    • Total: 5

    Thanks, I have just done this small test.

    Two uiToggleButton alone, which can be 1 or 0, no problem.
    If I put them two in a Radio group I start to have the issue where the two uiToggleButton always returns 1 even if the checked state displayed is “01” or “10”.

    #71417
    goodweather
    Participant
    • Topics: 45
    • Replies: 550
    • Total: 595
    • ★★★

    I have now done the same test during my lunch 🙂
    I answered a bit fast yesterday by following what you did…

    You need in fact to retrieve the value of the Components and not the Modulator!
    So, you should use the following code that works fine

    console(tostring(panel:getModulatorByName("typeRoom"):getComponent():getValue()))
    console(tostring(panel:getModulatorByName("typeHall"):getComponent():getValue()))

    In my panel, I do all panel:getModulatorByName(“name”) in a method called at panel load. This is more efficient when you have a large number of components (getModulatorByName is searching line by line in a table of all components so better doing this only once)

    So:

    modReverbRoom = panel:getModulatorByName("typeRoom")
    modReverbHall = panel:getModulatorByName("typeHall")

    Then in my code I just use

    console(tostring(modReverbRoom:getComponent():getValue()))
    console(tostring(modReverbHall:getComponent():getValue()))
    #71418
    dashie
    Participant
    • Topics: 1
    • Replies: 4
    • Total: 5

    Oh thanks !
    I have seen at others place in the forum the same thing I have done, this may not be applicable for this ui component or API changed since.

    I will try after job with the component and using panel load hook.

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