Time delay in JavaS...
 
Notifications
Clear all

Time delay in JavaScript?

2 Posts
2 Users
0 Reactions
791 Views
(@ndw1138)
Active Member
Joined: 2 years ago
Posts: 5
Topic starter  

Apologies if this has been answered inside a couple searches and came up empty.  

 

setTimeout() doesn't seem to exist in simhub.  Is there anyway short of using nclac to add a timer or delay? 

Would appreciate any knowledge on the subject.  

 

Nathan 


   
Quote
(@doomsday)
Trusted Member
Joined: 3 years ago
Posts: 33
 

let time = timespantoseconds($prop('SystemInfoPlugin.Uptime'));
    
if (root.toggle == null) {
    root.toggle = false;
    root.triggerTime = time;
      delay1 = 10;
      delay2 = 5;
}    
if (time - root.triggerTime >= (root.toggle ? delay2 : delay1)) {    
    root.toggle = !root.toggle;
    root.triggerTime = time;
}

return root.toggle;


   
ReplyQuote
Share: