js analog for nscal...
 
Notifications
Clear all

[Solved] js analog for nscalc changed() function

4 Posts
3 Users
1 Likes
794 Views
(@nevermike)
New Member
Joined: 2 years ago
Posts: 2
Topic starter  

Hi!

 

Can someone tell me if there any way to make js analog for nscalc changed() function? I tried to use setTimeout, but it's not defined.

 

My case is to make visible last lap time text only when car cross the s/f line. So in nscalc it easy to write with changed(), but I want to write it in js as all other fx for dash use js also.

 

Thanks!


   
Quote
(@romainrob)
Honorable Member
Joined: 5 years ago
Posts: 530
 

Hi,
I use this:

function changed(delay, value) {
root['time'] = timespantoseconds($prop('SystemInfoPlugin.Uptime'));
root['oldstate'] = root['oldstate'] == null ? value : root['newstate'];
root['newstate'] = value;

if (root['newstate'] != root['oldstate'])
{
root['triggerTime'] = root['time'];
}

return root['triggerTime'] == null ? false : root['time'] - root['triggerTime'] <= delay/1000;
}


   
nevermike reacted
ReplyQuote
(@nevermike)
New Member
Joined: 2 years ago
Posts: 2
Topic starter  

@romainrob Thank you so much! Will try it.


   
ReplyQuote
(@f1arcade81)
New Member
Joined: 10 months ago
Posts: 2
 

Hi, I have this script to make the drs enable text appear on the 3rd lap. I would like this text to be visible for 10 seconds. What formula should I implement. Thank you!!!

var Leader = $prop('GarySwallowDataPlugin.Generic.LeadLap');

if (Leader == 3) {return true}

else return false


   
ReplyQuote
Share: