Replies: 5 comments 18 replies
-
Let's say you attached a method to luaModulatorValueChange of two buttons, button1 and button2, and you want to know which button is which: buttonNameOfButtonThatIsPressed = function(mod, value) -- Press a button, the value changed from 0 to 1 or vice versa, Ctrlr passes the value change on to the method. -- get the name of the modulator of which the value changed -- Lua knows the name of the modulator which value changed, now do something with it: Does that answer your question? |
Beta Was this translation helpful? Give feedback.
-
Try using: To manage several LEDs with one function, you use the method described above |
Beta Was this translation helpful? Give feedback.
-
OK. I repeat it for the 101th time (you can search for this in the old forum): 1/ Create a method called AssignModulators() like:
2/ Create a PanelLoaded() method that you attach to the panel property "Called when the panel ahs finish loading"
3/ good luck ;-) /goodweather |
Beta Was this translation helpful? Give feedback.
-
You might find this code useful. Also with regard to formatting code, I am using html <pre></pre> tags. Seems to work better! programSelect = function(mod,value,source) if source == 4 then local sName = L(mod:getName()) local t = {"PROGRAM01", "PROGRAM02", "PROGRAM03", "PROGRAM04"} -- local table of 4 radio buttons for i, v in pairs(t) do if sName == v then -- run code on clicked on button local sysMess = string.format("F0 00 00 23 01 43 C1 00 %.2X F7", i - 1) panel:sendMidiMessageNow(CtrlrMidiMessage(sysMess)) else -- run code on the other buttons that weren't clicked on _G[v]:setValue(0, true) -- don't use panel:getComponent(v) // use panel:getModulatorByName(v) end end end end -- source == 4 (user clicked on a button - not lua generated - that would be 5 or 6) --[[ *NOTE: Where PROGRAM01 etc are initialised in an init script "Called when the panel has finished loading" PROGRAM01=panel:getModulatorByName("PROGRAM01") PROGRAM02=panel:getModulatorByName("PROGRAM02") PROGRAM03=panel:getModulatorByName("PROGRAM03") PROGRAM04=panel:getModulatorByName("PROGRAM04") --]] |
Beta Was this translation helpful? Give feedback.
-
and also keep in mind that you can always combine strings and numbers without using the format function but by using the tostring() function:
or more in general
|
Beta Was this translation helpful? Give feedback.
-
I have several buttons calling each time the same LUA function when pressed. Does LUA know which button/modulator made the call? If so, how does that look in LUA speak? TIA!
Sjoerd W
Beta Was this translation helpful? Give feedback.
All reactions