Good Grief! It's been years since I looked at that bit of code. I don't even know if the present code is still what I created, or indeed what I have in my version.
But let's see what can be done.
Three things come to mind.
First, there is that well-known difference between activity/explorer mode and timetable mode regarding the interaction of speed limits set by signals and speed limits set by speedposts. So that things work differently in timetable mode compared to explorer mode does not really come as a surprise.
(NB - for anyone interested in these differences and the background therof - there is many a lengthy thread on this subject here in the vaults of Elvas Tower).
Second, it all works well without TCS scripts. I don't want to point any fingers, but ....
Third, any raise in speed limit is handled through a distance-travelled action event. So let's pick up the trail there and see where it will lead us.
Well, this trail leads directly to the method "SetPendingSpeedLimit" in train.cs, where the action event is processed.
This is (most of) the code of that method - well, at least in my version :
public void SetPendingSpeedLimit(ActivateSpeedLimit speedInfo)
{
float prevMaxSpeedMpS = AllowedMaxSpeedMpS;
if (speedInfo.MaxSpeedMpSSignal > 0)
{
allowedMaxSpeedSignalMpS = Simulator.TimetableMode ? speedInfo.MaxSpeedMpSSignal : allowedAbsoluteMaxSpeedSignalMpS;
AllowedMaxSpeedMpS = Math.Min(speedInfo.MaxSpeedMpSSignal, Math.Min(allowedMaxSpeedLimitMpS, allowedMaxTempSpeedLimitMpS));
}
if (speedInfo.MaxSpeedMpSLimit > 0)
{
allowedMaxSpeedLimitMpS = Simulator.TimetableMode ? speedInfo.MaxSpeedMpSLimit : allowedAbsoluteMaxSpeedLimitMpS;
if (Simulator.TimetableMode)
AllowedMaxSpeedMpS = speedInfo.MaxSpeedMpSLimit;
else
AllowedMaxSpeedMpS = Math.Min(speedInfo.MaxSpeedMpSLimit, Math.Min(allowedMaxSpeedSignalMpS, allowedMaxTempSpeedLimitMpS));
}
if (speedInfo.MaxTempSpeedMpSLimit > 0 && !Simulator.TimetableMode)
{
allowedMaxTempSpeedLimitMpS = allowedAbsoluteMaxTempSpeedLimitMpS;
AllowedMaxSpeedMpS = Math.Min(speedInfo.MaxTempSpeedMpSLimit, Math.Min(allowedMaxSpeedSignalMpS, allowedMaxSpeedLimitMpS));
}
So what does this tell us?
There are three variables here :
- allowedMaxSpeedSignalMpS : this variable is set only when an explicit speed restriction is set in relation to a signal aspect.
It is not updated based on aspect only - if the active aspect of a signal has no related speed restriction, the value remains unaltered.
- allowedMaxSpeedLimitMpS : this variable is set based on the speed limit as set in a speedpost.
- AllowedMaxSpeedMpS : this is the actual valid speed limit, its value is based on the values of the two variables above, and is derived from these variables according to the appropriate logic.
So, my conclusion is that you are using the wrong variable. The variable
AllowedMaxSpeedMpS should be used as that is the actual applied speedlimit.
This actually applies to both activity/explorer mode and timetable mode.
Regards,
Rob Roeterdink