The International Simutrans Forum

 

Author Topic: [pull request] yellow light of traffic lights  (Read 724 times)

0 Members and 1 Guest are viewing this topic.

Offline Phystam

  • Devotee
  • *
  • Posts: 524
  • Pak256.Ex developer
    • Pak256 wiki page
  • Languages: ja, en, eo
[pull request] yellow light of traffic lights
« on: June 07, 2021, 08:43:51 AM »
pull request: https://github.com/jamespetts/simutrans-extended/pull/389

This patch is related to this post: https://forum.simutrans.com/index.php/topic,20941.0.html
It introduces yellow lights to traffic signals to reduce the occurrence of congestion at intersections. You can define an additional yellow signal image, but you can also use it without defining one. In this case, the green signal image is used instead.
The default duration of phases is as follows:
N-S direction (16s)→ N-S yellow (2s) → E-W direction (16s) → E-W yellow (2s) → ...
https://cdn.discordapp.com/attachments/737992275220627456/851373920359546890/traffic_light.mp4

Offline Freahk

  • Devotee
  • *
  • Posts: 1585
  • Languages: DE, EN
Re: [pull request] yellow light of traffic lights
« Reply #1 on: June 07, 2021, 10:59:03 AM »
That's great :)

In this case, the green signal image is used instead.
Showing the red one in this case should be less confusing.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10818
  • Languages: De,EN,JP
Re: [pull request] yellow light of traffic lights
« Reply #2 on: June 07, 2021, 12:41:47 PM »
I think also red in all directions would be better, visually.

Furthermore, there is almost no extended related code in here, so I think I will try this patch also in standard.

Offline Phystam

  • Devotee
  • *
  • Posts: 524
  • Pak256.Ex developer
    • Pak256 wiki page
  • Languages: ja, en, eo
Re: [pull request] yellow light of traffic lights
« Reply #3 on: June 07, 2021, 01:11:05 PM »

As an example, here is an image in pak256. The top half of the image is an already existing image, the bottom half is a newly added image. Due to the compatibility of the image specifications, for example, "red light in the east, green light in the north", we need to draw a new image to specify all red lights. Of course, it would be more reasonable to draw a new image with a yellow light.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20915
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [pull request] yellow light of traffic lights
« Reply #4 on: June 08, 2021, 10:25:59 PM »
Thank you for this. Can I ask for an example of the syntax for the amber traffic light phase?

Offline Vladki

  • Devotee
  • *
  • Posts: 3726
    • My addons, mostly roadsigns, pak128.cs
  • Languages: EN, CS
Re: [pull request] yellow light of traffic lights
« Reply #5 on: June 09, 2021, 10:37:07 AM »
If this would lead to a significant rewrite of the traffic lights drawing routine, it would be nice to consider also rewrite for situations when the phases are not perpendicular. Now some images contain two lights, and iplicitly expect that if N-S is green, then E-W is red. However you can set any combination (at least in extended). E.g. Green for N-W, and red for S-E. Vehicles obey this setting, but visually it is confusing as cars are passing on red, and the player is then not sure if the setting is correct or not.

Offline Phystam

  • Devotee
  • *
  • Posts: 524
  • Pak256.Ex developer
    • Pak256 wiki page
  • Languages: ja, en, eo
Re: [pull request] yellow light of traffic lights
« Reply #6 on: June 09, 2021, 09:55:17 PM »
Image[0]-[15] are currently used images with red-green lights. You can use image[16]-[31] for amber lights additionally.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20915
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [pull request] yellow light of traffic lights
« Reply #7 on: June 12, 2021, 10:29:59 AM »
Image[0]-[15] are currently used images with red-green lights. You can use image[16]-[31] for amber lights additionally.

Thank you for that. I am trying to understand how this maps to the existing syntax. Currently, we have:

Code: [Select]
image[0]=./images/traffic-light-1920s-red_N.0.0
Image[1]=./images/traffic-light-1920s-red_S.0.0

Image[2]=./images/traffic-light-1920s-green_W.0.0
Image[3]=./images/traffic-light-1920s-green_E.0.0

Image[4]=./images/traffic-light-1920s-double-4.0.0
Image[5]=./images/traffic-light-1920s-double-5.0.0
Image[6]=./images/traffic-light-1920s-double-6.0.0
Image[7]=./images/traffic-light-1920s-double-7.0.0

image[8]=./images/traffic-light-1920s-green_N.0.0
Image[9]=./images/traffic-light-1920s-green_S.0.0

Image[10]=./images/traffic-light-1920s-red_W.0.0
Image[11]=./images/traffic-light-1920s-red_E.0.0

Image[12]=./images/traffic-light-1920s-double-12.0.0
Image[13]=./images/traffic-light-1920s-double-13.0.0
Image[14]=./images/traffic-light-1920s-double-14.0.0
Image[15]=./images/traffic-light-1920s-double-15.0.0

So we have N/S pairs of, in order, red, green and then doubles (pairs of red/green), and then the same pattern repeated with E/W pairs.

If we use 16-31 to give an amber phase, I imagine that we would have the first two being N/S pairs of amber - but presumably the next two would not be repeating the N/S phase of green - so what would images 18 and 19 represent?

And the doubles - currently, they are red/green pairs. Would these be red/amber or green/amber pairs? I am not sure from your description which images go where in the sequence, and it would help me to know this in order for me to test this new feature. Thank you.

Offline Phystam

  • Devotee
  • *
  • Posts: 524
  • Pak256.Ex developer
    • Pak256 wiki page
  • Languages: ja, en, eo
Re: [pull request] yellow light of traffic lights
« Reply #8 on: June 12, 2021, 01:48:32 PM »
What we need to do is just to replace the green lights with amber lights. These should be Amber/Red pair image.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20915
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [pull request] yellow light of traffic lights
« Reply #9 on: June 12, 2021, 07:02:06 PM »
What we need to do is just to replace the green lights with amber lights. These should be Amber/Red pair image.

In that case, would images 16 and 17 be identical to images 0 and 1? These are the single reds, so, if we are repeating the entire pattern again, but with green replaced with amber, the single reds would be repeated, I should imagine...?

Edit: I have been testing this on my traffic-light-amber branch of both code and pakset; however, I have been unable to make the amber phase display.

I have the following syntax (I am only testing with the earlier, 1920s traffic light so far):

Code: [Select]
image[0]=./images/traffic-light-1920s-red_N.0.0
Image[1]=./images/traffic-light-1920s-red_S.0.0

Image[2]=./images/traffic-light-1920s-green_W.0.0
Image[3]=./images/traffic-light-1920s-green_E.0.0

Image[4]=./images/traffic-light-1920s-double-4.0.0
Image[5]=./images/traffic-light-1920s-double-5.0.0
Image[6]=./images/traffic-light-1920s-double-6.0.0
Image[7]=./images/traffic-light-1920s-double-7.0.0

image[8]=./images/traffic-light-1920s-green_N.0.0
Image[9]=./images/traffic-light-1920s-green_S.0.0

Image[10]=./images/traffic-light-1920s-red_W.0.0
Image[11]=./images/traffic-light-1920s-red_E.0.0

Image[12]=./images/traffic-light-1920s-double-12.0.0
Image[13]=./images/traffic-light-1920s-double-13.0.0
Image[14]=./images/traffic-light-1920s-double-14.0.0
Image[15]=./images/traffic-light-1920s-double-15.0.0

image[16]=./images/traffic-light-1920s-red_N.0.0
Image[17]=./images/traffic-light-1920s-red_S.0.0

Image[18]=./images/traffic-light-1920s-amber_W.0.0
Image[19]=./images/traffic-light-1920s-amber_E.0.0

Image[20]=./images/traffic-light-1920s-double-amber-4.0.0
Image[21]=./images/traffic-light-1920s-double-amber-5.0.0
Image[22]=./images/traffic-light-1920s-double-amber-6.0.0
Image[23]=./images/traffic-light-1920s-double-amber-7.0.0

Image[24]=./images/traffic-light-1920s-amber_N.0.0
Image[25]=./images/traffic-light-1920s-amber_S.0.0

Image[26]=./images/traffic-light-1920s-red_W.0.0
Image[27]=./images/traffic-light-1920s-red_E.0.0

Image[28]=./images/traffic-light-1920s-double-amber-12.0.0
Image[29]=./images/traffic-light-1920s-double-amber-13.0.0
Image[30]=./images/traffic-light-1920s-double-amber-14.0.0
Image[31]=./images/traffic-light-1920s-double-amber-15.0.0

The traffic light behaves just as traffic lights behave in the current release version: they have only green and red phases.

I notice, however, that there is no change to any of the writer modules for makeobj. I suspect that this is why the additional phases are not displaying, as I imagine that the existing makeobj code does not write more than the original 16 images.

Can you clarify whether the graphical representation of the amber phase has been tested, and, if so, whether the code that I have used above is correct?
« Last Edit: June 12, 2021, 08:00:19 PM by jamespetts »

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20915
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [pull request] yellow light of traffic lights
« Reply #10 on: June 13, 2021, 01:16:30 PM »
Phystam - thank you for your help on Discord. As I explained there, the problem that I was having turned out to be my error for not running the proper script for moving the files to the correct location once I had built the pakset.

I have now tested this and added amber phases to all three types of traffic lights in Pak128.Britain-Ex, and merged this with the master branch. This feature should be available from to-morrow's nightly build. Thank you for your work on this!

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10818
  • Languages: De,EN,JP
Re: [pull request] yellow light of traffic lights
« Reply #11 on: June 14, 2021, 08:12:50 AM »
Inorporated in standard as r9887

Offline Phystam

  • Devotee
  • *
  • Posts: 524
  • Pak256.Ex developer
    • Pak256 wiki page
  • Languages: ja, en, eo
Re: [pull request] yellow light of traffic lights
« Reply #12 on: June 14, 2021, 11:06:56 AM »
James changed 'yellow' in the code into 'amber'. Did you confirm it?

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20915
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [pull request] yellow light of traffic lights
« Reply #13 on: June 14, 2021, 01:52:36 PM »
James changed 'yellow' in the code into 'amber'. Did you confirm it?

Yes, it is probably better to make sure that these be synchronised between Extended and Standard, and "amber" is the standard description of the more orange colour used in traffic lights; "yellow" tends to be used in railway signalling.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10818
  • Languages: De,EN,JP
Re: [pull request] yellow light of traffic lights
« Reply #14 on: June 14, 2021, 03:41:19 PM »
In German it would be yellow. However, there were several formatting issues and the switch was strange too. Also the standard patch includes more than 24 images for traffic lights, which was not allowed before.

I happily change to amber though. but it is already past midnight here.