The online racing simulator
LFSLapper:Cruise TrafficLightSystem
Hello,

I had this script laying around, which was used for a cruiseserver. The cruiseserver shut down for a while now, and i dont think it will be restarted anytime soon.
So i thought to edit the system for public use. Because it had some functions and variables from the main cruiseinsim.

Some features may not work properly, althought i tested some stuff and it seems to work fine. Please let me know if something isnt working, so i can look into it and fix it (if possible).
Describe the bug so detailed as possible.

Download cruise_trafficlight.txt and change the extention from .txt to .lpr.
Add the file into you 'includes' folder and add the script into addonsused.lpr


Features:
  • Create/Load/Save/Edit intersections
  • Enable/Disable intersections: light will blink yellow.
  • Add Startlights + Edit their ID's
  • Camerasystem for speeding and running red light
  • Automatic/Manual system for light sequence.
Todo list:
  • Speedlimit for each light
It is possible to save the intersections you created.
You can do that by remove the # infront of:
#GlobalVar $TrafficLightFolder; $TrafficLightFolder = "C:\Users\Danny\Desktop\SavedTrafficLights";

and set your own folder to save/load your intersections.

=========================================
How to setup a intersection:
=========================================
  • Add with the LayoutEditor some Startlights and give the lights a ID number
  • Add insimcircles so system sets the approaching Light to the player.
  • Add Insim finishlines for the redlight/speedcam system.
  • Type !trafficlight and create an intersection
  • Add the lights and set the lightID's (same ID's you used in the layoutbuilder)
  • To enable camerasystem. Set the camera to "1" and change the incimcircle ID's (same ID's you used in the layoutbuilder)
  • Enable the intersection by set the control to "AUTO" and Set the Intersection to "ON"


Attached images
TF#1.PNG
TF#2.PNG
TF#3.PNG
TF#4.PNG
Attached files
cruise_trafficlight.txt - 42.2 KB - 287 views
Wow, this is a very nice system with a great GUI.
I am sure people will start using this, so thanks for sharing and making this.
Quote from Yisc[NL :;1967450"]Wow, this is a very nice system with a great GUI.
I am sure people will start using this, so thanks for sharing and making this.

Thank you Smile
What code should I add to addonsused.lpr? I only need one traffic light near the exit of my drift track
Start/Configure the trafficlight script with the command!trafficlight
The code in this script is based on a loop that runs continuously.
So the trafficlight wont be activated by detection.

But looking at your question. you want to have the Red > Green > Yellow > Red sequence i think.

You can look a the code below the function
Sub TrafficLoop()

If you wan to create something yourself, here is a simple example.
Execute Sub Red_Yellow_light().
Caution: i havent tested this.

Sub Red_Yellow_light()
startlightcontrol(5,149,1,1); #LightID = 1
delayedcommand("GoToYellowLight",5,Yellow_Green_light); #duration 5 seconds
EndSub

Sub Yellow_Green_light()
startlightcontrol(5,149,1,2); #LightID = 1
delayedcommand("GoToGreenLight",2,Green_Yellow_Light); #duration 2 seconds
EndSub

Sub Green_Yellow_Light()
startlightcontrol(5,149,1,8); #LightID = 1
delayedcommand("GoToYellowLight",6,Yellow_Red_Light); #duration 6 seconds
EndSub

Sub Yellow_Red_Light()
startlightcontrol(5,149,1,2); #LightID = 1
delayedcommand("GoToRedLight",2,Red_Yellow_light); #duration 2 seconds
EndSub

Thank you very much for the quick response. I'm creating a drift server, so I need one of the traffic lights to just keep switching continuously.

Currently, if I place a traffic light via LYTeditor, it switches from red to green and then stays on green (when the race starts). But I need it to simply change every few seconds, and that's it.

Thanks for the instructions, I'll keep battling with the server setup Smile
Attached images
Untitled.jpg
Try the following:
  • Create an intersection
  • Click EDIT
  • Select type intersection number 4 ( pedestrian-crossing)
  • Add two trafficlights
  • Edit the LightIDs: one must be the actual startlight ID you placed, and one lightID that isnt in use.
  • Automatic contol to AUTO
  • Enable the intersection

Attached images
light.jpg
Thank you for your patience. Manual switching is working now. But when I set it to Auto, the color doesn’t switch to red. I don’t understand something. I thought it would be 2 seconds green, 2 seconds red, and keep switching like that continuously. I’ll keep experimenting. Thank you very much for your instructions and for everything you’ve created for the LFS community.
Attached images
Untitled.jpg
Maybe the loop stopped for some reason, you can reset the loop with !resettrafficloop

And thank you for the kind words.

FGED GREDG RDFGDR GSFDG