The online racing simulator
LFSLapper adding ISP_OCO packet (StartLight Control)
Hello everyone,

Today i started with implementing the OCO packet in LFSLapper.

After a few tests , the startlight control works good, so far.

You can control the startlights by using a new function:

LapperFunction:
startlightcontrol(5,149,1,1);
startlightcontrol($LightAction,$LightIndex,$LightIndentifier,$LightColor);

Be sure those vars are GlobalVars.

$LightAction:

#4 = OCO_LIGHTS_RESET, // give up control of all lights
#5 = OCO_LIGHTS_SET, // use Data byte to set the bulbs
#6 = OCO_LIGHTS_UNSET, // give up control of the specified lights

$LightIndex:

AXO_START_LIGHTS (149) or STARTLIGHTS_TRACK (240)

$LightIndentifier:

identify particular start lights objects (0 to 63 or 255 = all)

You can give each StartLight a differend number in AutoX editor:

$LightColor:


STARTLIGHTS_TRACK(240) AXO_START_LIGHTS(149)
0 = off 0 = off
1 = red1 1 = red
2 = red2 2 = amber
4 = red3 -
8 = green 8 = green

First testversion will be released soon.
Attached images
StartLight1.jpg
Thumbs up

Looks like you'll have to change your teamname from Impact to DISCO!
Here is the Test Version:

For documentation see first post.
I'm not sure what RESET and UNSET does.

Have Fun

Changes:

[Add]OCO Packet(Startlight Control) (Test)
[Change]ObjectHit: All_Railings' renamed to 'All_Armco'

Edit: Released new LFSLapper version 7.0.4.0 , See Release Thread
You can use the real traffic light to drag?
you can use the startlights for drag. But you cannot place those startlights in demo.
What have you called this Event?

Checking LFSLapper.lpr between your V7.030 and V7.031, the only difference I can see is that the explanation for breakdown of using Private Buttons has been copied under the #Action when a new Gapping Info is available# section.

Also, in the managePacket.cs file

Object[96] = "Short Railing"; Object[97] = "Medium Railing"; Object[98] = "Long Railing"; // Not moveable Railing

if (newCfg.varsLapper.DetectHitObject.Contains("All_Railings") && (obh.Index > 95 && obh.Index < 99))

Is this the file that should have these railings changed to Armco?
Its not a event, its a LapperFunction. See first post.

I havent copied the "src"folder, to the testversion. But 'All_Armco' should work.
And Objectnames ( Short/Medium/Long) Armco should work too
I've been struggling testing for few hours with a setup of 3 autox lights all side by side, and set identifiers to 0, 1 and 2.

Took me long time with nothing happening before I thought to actually enable lights first like I was about to start a race.

Once I'd finally got figured that out....

startlightcontrol(5,149,0,1);

to set 1 of the 3 lights to red. This worked.

I realise that you can have multiple start lights with same identifier, and code will work on all identified lights as one.


Got above image by running lapper 3 times, with idents 0,1,2,0,1,2,0,1,2


However, for the next bits I need help.

Can't work out how to enable more than 1 set of lights at a time.

Tried the following in 3 lines, one line after another
startlightcontrol(5,149,0,1);
startlightcontrol(5,149,1,2);
startlightcontrol(5,149,2,8);

All resulted in lapper crashing.

Also.

Tried setting sub to trigger a change in lights (say if green, trigger to amber), but lapper didn't like the vars I put in the sub header. Tried
Sub lights ()
Sub lights ($KeyFlags,$id)
Sub lights ($LightAction,$LightIndex,$LightIndentifier,$LightColor)

but these just resulted in lapper having a fit.

After testing, found that you can use Insim Circles as triggers, but these might be too big in certain circumstances
IF ( $CircleIndex == "1" )
THEN
startlightcontrol (5,149,1,2); # set all ident 1 lights to amber
ENDIF

and you can also use Insim Checkpoints as triggers too, although not sure if lapper can differentiate between one kind of checkpoint and another (eg Finish Line v 1st Checkpoint)

IF ( $Flags == "2" )
THEN
startlightcontrol (5,149,1,8); # set all ident 1 lights to green
ENDIF

although might be possible to fiddle about with IF ($LightColor = n) THEN ... ?

Help!
Attached images
lights.png
I can set 12 startlightcontrol() functions without crashing.

startlightcontrol(5,149,0,1);
startlightcontrol(5,149,1,1);
startlightcontrol(5,149,2,1);
startlightcontrol(5,149,3,1);
startlightcontrol(5,149,4,1);
startlightcontrol(5,149,5,1);
startlightcontrol(5,149,6,8);
startlightcontrol(5,149,7,1);
startlightcontrol(5,149,8,1);
startlightcontrol(5,149,9,1);
startlightcontrol(5,149,10,1);
startlightcontrol(5,149,11,1);

Dont know what you mean about the Sub thing.
for testing the light i used this code.

EDIT: Moved example/test script to file
Attached files
LFSLapper_Lights_SetGet_Example.txt - 3.6 KB - 607 views
Ill push this update(7.0.3.1) as official release next weekend. Maybe sooner.
New Version will be (7.0.4.0).
i follow your instructions and it works ! wow Big grin

now i need to reach next level :
- blinking lights yellow (main & startlights) for yellow flag advertising
- fix light yellow on startlights autocross object (or red for main) for "ready ? prepare to continue race"
- fix green light on all lights for "green flag"
+ RCM message for each lights status (" YELLOW FLAG " / "READY ? SAFETY CAR IN PIT" / " GREEN FLAG - GO ! ")

all these 3 lights setting must be triggered by a simple command wich could be assigned to a key Smile

for example : Dekojester has a app to do that and triggered just by pressing command "@green", "@yellow" or "@green"

here is the point where i am blocked (i am not a coding master Confused ) : you 'll find a layout wich is working with the lpr above

i especially need this function for oval events we organize at GUM Garage !LFS
i organise but also manage the GUM team and run the race, so the key press is the solution for controlling Lights and restart
Attached images
2020-06-05 18-02-16.667.jpg
Attached files
KY1_GUM ovalpit Lights.lyt - 1.1 KB - 189 views
Have a go with the attached script.
It does all that you asked for, except the blinking yellow lights on main, as there is no yellow state on them.
So made them blink red.

I've put the commands !ylw , !rdy , !grn under my F5,F6,F7 (you need to do that in your own LFS settings (see screenshot) and it's working as intended.

Change the extension of the file to .lpr and add it to addonsused.lpr to be able to use it.
Attached images
Capture.PNG
Attached files
oval_lights_controller.txt - 3.7 KB - 213 views
Oval lights controller - V1.01
Small update (V1.01) to this script with the following change log:

-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

Change the extension of the file to .lpr and add it to addonsused.lpr to be able to use it.
Attached files
oval_lights_controller.txt - 4.1 KB - 211 views
Ya right wow !! very impressive ; it works so well Thumbs up
me and the GUM garage member are really happy and thanks to you for this very fast reacting coding answer ! Hug

omg ! we 'll have more immersive Nascar and Oval events now !! 1000thanks Boss ! Omg omg omg

LFSLFSLFS


yyyyhaaa ! Na-na

FGED GREDG RDFGDR GSFDG