onPotTouch | If the recommendation from the Lua messages is followed, the function will not work

I get the following error message:

17:37:46.693 onPotTouch function will be deprecated. Use onPotTouchChange instead.

If I simply replace “onPotTouch” with “onPotTouchChange” it immediately stops working. What “magic” is additionally required to maintain the functionality?

Hi,

The developer guide has a typo (cc @martin) , it returns the touched PotId in range 1-12 (for E1 Mk 2), assume this is in range 1-8 for the Mini:

I have used this print statement in the event handler before to help me debug:

function events.onPotTouchChange(potId, controlId, touched)
  print ("potId: " .. potId .. ", controlId: " .. controlId .. ", touched: " .. (touched and "yes" or "no"))
 
  doStuff(potId, controlId, touched)
end
3 Likes

Oh and don’t forget to set up the events subscription in your preset’s preset.onReady() callback handler:

function preset.onReady()

   events.subscribe(POTS)

end
2 Likes

Thanks so much @Phommed for your response.

I also recognized the typo as I was looking into the API-LuaExtension. I inserted your print statement and it showed that everything seemed to work accordingly - as long as I used the “old” term “onPotTouch”. As soon as I changed it to “onPotTouchChange” it immediately stopped working. But the print statements still looked good.

I was about to give up because it worked at least but comparing both versions with your print statement solved the problem.

The previous term “onPotTouch” counted the Pots from 0 … 11 (on the MK2). The new term starts counting from 1. :roll_eyes:

Thanks again and enjoy the rest of your weekend!

3 Likes

I fixed the Page vs Pot mistake. Good point about 1-12. I need to come up with some general way to address this everywhere where there is a difference between the Mini and the OG mk2.

1 Like

And in general stick to one way of enumeration everywhere: either always start at 0 or always start at 1. (Eg also bank, slot index)

There is a bit of a hassle here. Lua uses 1-based indices, while in SysEx I stay with 0-based. I am trying to stick to that rule. eg, the change of onPotTouch was primarily motivated by making that Lua function inline with that. Not that I like it, but it is how it is now.