# Author: Yisc[NL] # # Lapper version needed: 7.0.4.10 or above # # # # Oval lights controller V1.00 07-07-2020 -Initial release # # Oval lights controller V1.01 07-07-2020 -Made the main lights blink left one / right one on command !ylw # # -Added code to switch off actions on Yellow when going straight into !grn # ######################################################################################################################################################################### CatchEvent OnLapperStart() GlobalVar $RCM_status; GlobalVar $RCM_loop_count; GlobalVar $Yellow_status; $RCM_status = 0; $RCM_loop_count = 0; EndCatchEvent CatchEvent OnMSO( $userName, $text ) # Player event $idxOfFirtsSpace = indexOf( $text, " "); IF( $idxOfFirtsSpace == -1 ) THEN $command = $text; $argv = ""; ELSE $command = subStr( $text,0,$idxOfFirtsSpace ); $argv = trim( subStr( $text,$idxOfFirtsSpace ) ); ENDIF SWITCH( $command ) CASE "!ylw": $Yellow_status = "on"; SetYellowLight_On(); BREAK: CASE "!rdy": $RCM_status = 0; $RCM_loop_count = 0; $Yellow_status = "off"; DelayedCommand( 1, SetLightsReady ); BREAK: CASE "!grn": $RCM_status = 0; $RCM_loop_count = 0; $Yellow_status = "off"; DelayedCommand( 1, SetLightsGreen ); BREAK: ENDSWITCH EndCatchEvent Sub SetYellowLight_On() $LightAction = 5; #Set lights to a defined color $LightIndex = 149; #AXO_START_LIGHTS $LightIndentifier = 255; #All lights $LightColor = 2; #Red (tracklights) , Amber (Autocross lights) startlightcontrol($LightAction,$LightIndex,$LightIndentifier,$LightColor); $LightIndex = 240; #STARTLIGHTS_TRACK $LightColor = 1; #Red (tracklights) (left light) startlightcontrol($LightAction,$LightIndex,$LightIndentifier,$LightColor); ### Only display a Race Control Message if value of RCM_status is 0 ### ### Set value of RCM_status to 1 after displaying the message ### IF ( $RCM_status == 0 ) THEN cmdLFS( "/rcm ^3YELLOW FLAG" ); cmdLFS( "/rcm_all" ); $RCM_status = 1; ENDIF ### End ### IF ( $Yellow_status == "on" ) THEN DelayedCommand( 1, SetYellowLight_Off ); ENDIF EndSub Sub SetYellowLight_Off() $LightAction = 5; #Set lights to a defined color $LightIndex = 149; #AXO_START_LIGHTS $LightIndentifier = 255; #All lights $LightColor = 0; #Off startlightcontrol($LightAction,$LightIndex,$LightIndentifier,$LightColor); $LightIndex = 240; #STARTLIGHTS_TRACK $LightColor = 4; #Red (tracklights) (right light) startlightcontrol($LightAction,$LightIndex,$LightIndentifier,$LightColor); ### Rais RCM_loop_count by 1 ### $RCM_loop_count = $RCM_loop_count + 1; ### End ### ### Check if RCM_loop_count reached the value of 5 ### ### If so, set RCM_status to 0 , set RCM_loop_count to 0 ### IF ( $RCM_loop_count == 5 ) THEN $RCM_status = 0; $RCM_loop_count = 0; ENDIF ### End ### IF ( $Yellow_status == "on" ) THEN DelayedCommand( 1, SetYellowLight_On ); ENDIF EndSub Sub SetLightsReady() $LightAction = 5; #Set lights to a defined color $LightIndex = 149; #AXO_START_LIGHTS $LightIndentifier = 255; #All lights $LightColor = 2; #Red (tracklights) , Amber (Autocross lights) startlightcontrol($LightAction,$LightIndex,$LightIndentifier,$LightColor); $LightIndex = 240; #STARTLIGHTS_TRACK startlightcontrol($LightAction,$LightIndex,$LightIndentifier,$LightColor); cmdLFS( "/rcm ^1READY ? SAFETY CAR IN PIT" ); cmdLFS( "/rcm_all" ); EndSub Sub SetLightsGreen() $LightAction = 5; #Set lights to a defined color $LightIndex = 149; #AXO_START_LIGHTS $LightIndentifier = 255; #All lights $LightColor = 8; #Green (tracklights) , Green (Autocross lights) startlightcontrol($LightAction,$LightIndex,$LightIndentifier,$LightColor); $LightIndex = 240; #STARTLIGHTS_TRACK startlightcontrol($LightAction,$LightIndex,$LightIndentifier,$LightColor); cmdLFS( "/rcm ^2GREEN FLAG - GO !" ); cmdLFS( "/rcm_all" ); EndSub