Need help with writ...
 
Notifications
Clear all

Need help with writing script with multiple functions.

5 Posts
4 Users
0 Reactions
3,284 Views
 DND
(@dnd)
New Member
Joined: 4 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: 8 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: 4 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: 2 years ago
Posts: 4
 

Thank you!


   
ReplyQuote
(@andrewsinn)
New Member
Joined: 1 month ago
Posts: 1
 

Posted by: @dnd

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 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)

 If you're looking for something equally engaging to unwind with, I suggest trying <a href=" removed link " target="_new" rel="noopener" data-start="304" data-end="338"> removed link . I've personally enjoyed their smooth gameplay, great selection of slots, and rewarding bonuses. It’s definitely worth checking out.

<div class="group/conversation-turn relative flex w-full min-w-0 flex-col agent-turn @xs/thread:px-0 @sm removed link @md/thread:px-4">

I like how you're breaking down the logic for lap time comparisons — it’s always satisfying to see clear conditions in action. Assigning color outputs can get tricky, but once done, it's a great way to visualize progress.

 


   
ReplyQuote
Share: