How To | Scripting a delay in Q-SYS

Learn how to script a delay in Q-SYS.

Updated at May 8th, 2023

Your engagement helps us create the content you need. Click here to review this article.



Table of Contents

Procedure


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[1].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[1].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