Due to increasing spam attacks, forum registrations are currently paused to keep our community safe and spam-free. Come hang out and stay connected with us on the SimHub Discord: https://discord.com/invite/nBBMuX7!

Catch you on Discord — and thanks for understanding!
Need help with writ...
 
Notifications
Clear all

Need help with writing script with multiple functions.

5 Posts
4 Users
0 Reactions
6,266 Views
 DND
(@dnd)
New Member
Joined: 5 years ago
Posts: 4
Topic starter  

Trying to use the IF command to write a function for the color of Last Lap determined on the Previous and Best Laps.

Last Lap Time = Previous Lap Time then color is YELLOW

Last Lap Time <  Best Lap Time then color is PURPLE

Last Lap Time < Previous Lap Time and is > Best Lap Time then color is GREEN

Last Lap Time > Previous Lap Time then color is RED

I was thinking this would work if it would stop after it found a TRUE statement, but not sure how to assign color.

if([LastLapTime]<[PersistantTrackerPlugin.SessionBest],PURPLE,[LastLapTime]>[PersistantTrackerPlugin.PreviousLap_00],RED,[LastLapTime]<[PersistantTrackerPlugin.PreviousLap_00],GREEN)



   
Quote
(@admin5435)
Prominent Member Admin
Joined: 9 years ago
Posts: 737
 

Hi ! To compare time you will need to compare them as seconds, you can use timespantoseconds function to convert it. Considering the colors, it has to be rgb encoded for green it's  '#00FF00' for instance (don't forget the quotes) 

About the "if", it's if(condition, trueresult, falseresult) so you can cascade ifs like excel :
 if(condition, trueresult, if(seconddontition, trueresult, if(thirdcondition, trueresult, falseresult))) 



   
ReplyQuote
 DND
(@dnd)
New Member
Joined: 5 years ago
Posts: 4
Topic starter  

@admin5435 Thank you for your help. Although the app accepted the script it fails in that all times are Yellow. I suspect that I have two problems...at least. This is in rFactor2.

1. in the second command I have two arguments to address a faster LastLap than PreviousLap but slower than the BestLap, is that acceptable?

2. The LastLap will never be Purple as it compares to BestLap which is updated simultaneously and then also fails to Yellow. I don't see a PreviousBestLap

if(timespantoseconds([LastLapTime])<timespantoseconds([BestLapTime]),'#800080',if(timespantoseconds([LastLapTime])<timespantoseconds([PersistantTrackerPlugin.PreviousLap_00])>timespantoseconds([BestLapTime]),'#008000',if(timespantoseconds([LastLapTime])>timespantoseconds([PersistantTrackerPlugin.PreviousLap_00]),'#FF0000','#FFFF00')))



   
ReplyQuote
(@mario5)
New Member
Joined: 3 years ago
Posts: 4
 

Thank you!



   
ReplyQuote
(@kerniol)
Active Member
Joined: 12 months ago
Posts: 17
 

Recently in India our company introduced internal checks for AI generated reports before sending them to partners. We needed something accurate but also free. I tested the best safeassign AI checker to see if it fits our workflow. It processes documents in seconds, detects AI patterns from multiple models, and doesn’t require account registration or hidden fees, which is useful for teams that just need quick verification without installing extra software. It works reliably for everyday document reviews.



   
ReplyQuote
Share:
📄 Terms & Conditions | 📑 Privacy Policy