How do I program a delay between two key commands in my script, each of which I have set to a custom variable?
// here I need a short delay = ca. 500 ms
In the API there is something like this:
makeRepeating (delaySeconds : number, rateHz : number) : Repeating
But what exactly does my code above need to look like?
Please avoid using this for this purpose. This is a very useful option when we want continuously change to a parameter or a command execution mainly with buttons. For example, I’m using this for triggering the bar ± command with buttons and it works great.
Now, to your question. As you most probably found out already, there is no “sleep” functionality embedded in the API. So we need to workaround this a bit.
Here’s a snippet based on my Komplete Kontrol MK2 script where I needed to implement double-clicking:
//Here we trigger the timer, this can be done for example inside the mOnProcessValueChange of our first custom var
var initTime = new Date().getTime()
var currentTime=new Date().getTime()
//we retrigger here
//trigger here whichever custom var you want
Note that most probably this function will not be of the best accuracy, but I guess it’s ok.
Thanks for your kind help.
This looks good.
I have been looking for something like that.