Home › Forums › General › Programming › Issue with getModulatorValue
- This topic has 4 replies, 2 voices, and was last updated 7 years, 2 months ago by dashie.
-
AuthorPosts
-
February 20, 2017 at 2:49 pm #71398
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
February 20, 2017 at 6:43 pm #71399Without 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.
February 20, 2017 at 6:59 pm #71401Thanks, 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”.February 21, 2017 at 1:49 pm #71417I 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 fineconsole(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()))
February 21, 2017 at 2:00 pm #71418Oh 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.
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.