LUA Plugins - Sleep function

Is there a way to have something like a Sleep function in LUA scripts?
I’ve had no success in trying this, because the environment is restricted, I guess, or I just don’t know the proper way to do it.

The Lua scripting is pretty limited to sequences of commands that are used in the normal running of the app. So anything you can do with the mouse can be scripted.

I’m not sure what you mean by a Sleep function, though. Do you want to put the computer to sleep (which Dorico normally prevents), or something else?

In programming, a sleep function makes the script/program wait for some milliseconds/seconds.

Can you briefly elaborate what you need this for?

The waiting in a script is to allow the computer to “catch up” between commands in the script. Otherwise the computer might miss a command that appears too quickly for it to recognize.

1 Like

Usually a quick fix to avoid a race condition!

A quick google for “Lua wait function” gave me this:

https://www.codegrepper.com/code-examples/lua/wait+function+lua

Thanks for trying to help, but I know how to use Google. The question is more complex than that, because you are not in a usual LUA environment, etc.

I have a good deal of experience with Dorico’s Lua capabilities. A sleep function is a bit tricky (sometimes apparently impossible), depending on circumstances. To say something more meaningful, I really would have to know more specifically what the problem is that you need to solve.

Waiting something like three seconds for the user to click something manually that can’t otherwise be done via recording macros, and then the script continues.
If it’s rather complicated (as I imagined), then I’ll just forget about it, it’s not critical.