0
Beantwoord

Adding a delay in Javascript

Iain Brew 6 jaar geleden bijgewerkt 6 jaar geleden 3

I am using Javascript to trigger a sequence of events in response to a button press. This is working well, however sometimes commands are skipped as I am not putting in delays. In the GUI side of iRidium this is easy by clicking on Delay and adding an 'ms' value. I have read through the documentation and haven't found how iRidium defines the equivalent when using JS/iRidium script i.e. IR.Delay = 300ms for example.

What is the best way to insert a JS delay?

IR.GetDevice("FMHS-ALERTSPKR-01").Set("Lab1_Alert_Playlist", ""),
IR.GetDevice("FMHS-ALERTSPKR-01").Set("play_sound", ""),
<INSERT A DELAY HERE>
IR.GetDevice("FMHS-ALERTSPKR-02").Set("Lab1_Alert_Playlist", ""),
IR.GetDevice("FMHS-ALERTSPKR-02").Set("play_sound", ""),
Under review

Hello.

In Javascript, use the IR.SetTimeout method to get the delay.

IR.GetDevice("FMHS-ALERTSPKR-01").Set("Lab1_Alert_Playlist", ""),	
	IR.GetDevice("FMHS-ALERTSPKR-01").Set("play_sound", ""),
function doSecondThing()
{		
	IR.GetDevice("FMHS-ALERTSPKR-02").Set("Lab1_Alert_Playlist", ""),
	IR.GetDevice("FMHS-ALERTSPKR-02").Set("play_sound", ""),
}
IR.SetTimeout(2000, doSecondThing);