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)
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)))
@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')))
Thank you!