How To | Scripting a delay in Q-SYS
Learn how to script a delay in Q-SYS.
If you are not finding the results you need and still have questions, submit a request using the form below and our Tech Docs team will get right on it. Our goal is to provide the content you need!
Your engagement helps us create the content you need. Click here to review this article.
Table of Contents
The Timer object built into Lua in Q-SYS has a CallAfter function. This is known as a "simple timer" and is described in the Q-SYS Help here.
The concept is as follows:
Timer.CallAfter(function() --[[the stuff to do after the TimeInSeconds value is complete]] end, TimeInSeconds)
For example, if you have a momentary button that needs to be toggled without a user button press:
TimeInSeconds = 3.5 --Define the amount of time to wait to do the function Controls.Button.Value = 1 --Sets the first Control named Button to a high position Timer.CallAfter(function() --The Simple Timer function that will be delayed Controls.Button.Value = 0 --Sets the first Control named Button to a low position end, TimeInSeconds) --Ends the instructions nested in the Simple Timer with the Delay Defined