Hello everyone,
I'm still working on a belgian signalling
package but I'm facing a last (?) problem. In a specific belgian
line, you have an automatic signal that onlye have red or green as
possible aspects. This signal is located before a signal that may
take the red, green or yellow_yellow aspects.
When the
next signal is red, aspect of the signal must be red.
When the
next signal is yellow_yellow or green, aspect of the signal must be
green.
When the aspect of the next signal changes to red,
aspect of the signal must be red but when doing so, aspect becomes
red but the track is still reserved. Is there a solution so that the
track before is not reserved anymore if the signal is automatically
set to red when the next signal becomes red ?
You will
find the script I use hereunder and two pictures to illustrate the
situation.
Thank you for your answer :) !
--
#
N.Gomrée 06/01/2018, based on P.Rosati RFI pack
Aspect:
red
IconE: NN_rb_E.xpm
IconW: NN_rb_W.xpm
IconN:
NN_rb_N.xpm
IconS: NN_rb_S.xpm
Action: stop
Aspect:
green
IconE: NN_gb_E.xpm
IconW: NN_gb_W.xpm
IconN:
NN_gb_N.xpm
IconS: NN_gb_S.xpm
Action: proceed
#
INITIAL ASPECT
OnInit:
.aspect = red
.fleeted
= 1
end
# USER CLICKED ON THE SIGNAL
OnCleared:
if
next.aspect = red or next.aspect = red_white or next.aspect =
red_white_Rx or next.aspect = red_white_Rxx
.aspect =
red
return
end
if next.aspect = yellow_yellow or
next.aspect = yellow_green
.aspect = green
return
end
if
next.aspect = green or next.aspect = green_yellow
.aspect =
green
return
end
if next.aspect =
yellow_yellow_Rx or next.aspect = yellow_yellow_Rxx or next.aspect =
yellow_yellow_Rxxx or next.aspect= green_Rx or next.aspect =
green_Rxx or next.aspect = green_Rxxx or next.aspect =
green_yellow_Rx or next.aspect = green_yellow_Rxx or next.aspect =
green_yellow_Rxxx or next.aspect = yellow_green_Rx or next.aspect =
green_yellow_Rxx or next.aspect = green_yellow_Rxxx
.aspect =
green
end
end
# ANOTHER SIGNAL CHANGED
ASPECT
OnUpdate:
if .aspect =
red
return
end
if next.aspect = red or
next.aspect = red_white or next.aspect = red_white_Rx or next.aspect
= red_white_Rxx
.aspect = red
return
end
if
next.aspect = yellow_yellow or next.aspect = yellow_green
.aspect
= green
return
end
if next.aspect = green or
next.aspect = green_yellow
.aspect = green
return
end
if
next.aspect = yellow_yellow_Rx or next.aspect = yellow_yellow_Rxx or
next.aspect = yellow_yellow_Rxxx or next.aspect= green_Rx or
next.aspect = green_Rxx or next.aspect = green_Rxxx or next.aspect =
green_yellow_Rx or next.aspect = green_yellow_Rxx or next.aspect =
green_yellow_Rxxx or next.aspect = yellow_green_Rx or next.aspect =
green_yellow_Rxx or next.aspect = green_yellow_Rxxx
.aspect =
green
end
end
end

When next signal is green, .aspect = green.
When next signal is red, .aspect = red but the track is still reserved.
Hi Nathan,
the reservation of the track occurs depending on the action associated to the aspect, not on the colours shown by the aspect itself or on its name.
Action: stop means signal is unclear: trains cannot pass the signal and the track after it is free.
Action: proceed or Action: speedLimit nn mean signal is clear: trains can pass it and track after it is reserved.
Action: none means the signal is transparent (typically a distant): trains can always pass it and track reservation is controlled by the nearest previous signal that shows an aspect with an action that is not none.
The default red and green aspects are associated to the stop and proceed actions by convention, as the simulator can associate any action to any aspect name.
In the signal script you change aspects only between those with the same action, as clearing and unclearing is usually done externally by the player or other scripts. You can simulate a click on the signal to force its clearing or unclearing even inside the signal script, but then you have to check if the action is possible or was successful (whichever check is easier), and set or reset the aspect accordingly to keep it consistent with the track reservation, as the program will not do those checks on your behalf.
Normally the program will check if the clearing / unclearing action is possible, and if not nothing is executed in the signal script.
Paolo R.
--
Se non desideri piú essere abbonato a questo gruppo, invia un messaggio a traindir3+...@googlegroups.com
Per ulteriori opzioni, visita il gruppo alla pagina http://groups.google.com/group/traindir3?hl=it
---
You received this message because you are subscribed to the Google Groups "Traindir3" group.
To unsubscribe from this group and stop receiving emails from it, send an email to traindir3+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/traindir3/61bf761a-a33e-4e9b-bf94-1455053be882n%40googlegroups.com.
Hi Nathan,
because when you force the aspect in a script the program
just does that. It doesn't apply the new action if it's different.
This is for flexibility: the idea is that you can do almost
everything in scripts, but the program doesn't help you, you must
take care of everything and keep everything consistent. This power
is not easy to use - some scripts in the package are more than a
thousand lines long - but it's actually very very powerful.
To clear / unclear a signal in a script you set the click property of that signal to 1.
The click is ignored if the current aspect action of that signal is none, otherwise if the (un)clearing is possible, the track is (un)reserved and the OnClear or OnUnclear functions of that signal's script are executed, depending on its current aspect action being stop or something else. Those functions are responsible to set an aspect consistent with the new condition (cleared or uncleared), and then the usual OnUpdate cycle is executed on all sygnals to update their aspect if needed. Only after this the execution returns to the point where you set the click property to 1, to continue from where it was.
Needless to say, avoiding infinite loops in all of this is again up to you, and if you trigger a loop the program will crash instantly, leaving you to debug the script without seeing what it was doing before the crash.
Have a look at the scripts in the package, as interlocking with the following signal is simulated in this way (in Italy sometimes two consecutive signals cannot be cleared together, for example on station tracks where transit without stopping is not allowed).
You can use fake aspects - used only during the script execution - to intercept and distinguish if the (un)clearing comes from your script or from the player, and to avoid loops.
Writing a signal package is not an easy task: the last Italian package took 5 years to be developed...
Paolo
To view this discussion visit https://groups.google.com/d/msgid/traindir3/6c3a5aa8-c8eb-4566-8edd-5c497d969294n%40googlegroups.com.



Hi Nathan,
as red and green have different actions you have to use the click = 1 clause to change between them, in both directions.
You cannot set just the aspect to green if it's red, and you cannot set just the aspect to red if it's green.
Something like
if .aspect = red and next.aspect != red
.click = 1 # This clears the first signal (possible only if path to next signal is set and free)
else
if .aspect != red and next.aspect = red
.click = 1 # This unclears the first signal (always possible)
end
end
PaoloTo view this discussion visit https://groups.google.com/d/msgid/traindir3/4cd17444-274f-43c5-ae12-f7620e1ae205n%40googlegroups.com.
Hi Nathan.
You're right.
Approach signals - any signal showing an aspect with action none - are transparent to other signals (and to trains) so the next clause doesn't see them. You have to use nextApproach in this case; it will see the next signal if it's an approach one.
next will see the next non approach signal no matter how many approach signals are in between
nextApproach will see just the first next signal, and only if that signal shows a none aspect.
This means that in generic scripts you have to check all the approach aspects first - if they are meaningful - and only then you can check normal aspects, rememberig that they may occur after any number of approach signals.
Paolo
To view this discussion visit https://groups.google.com/d/msgid/traindir3/4db3771d-3746-482c-a91b-39433496a531n%40googlegroups.com.