Alternate First, Stack Second
This is a simple replacement script to the built-in behaviour of alternate platform signals.
When sending trains to alternate platforms, this script will first assign trains to free tracks, and only start stacking trains behind other trains when all tracks are occupied, rather than the built-in alternate platform signals that will first fill a track before moving on to the next one. This leads to slightly more realistic behaviour in busy stations, and can be very useful e.g. when parking trains at a terminus station overnight.
As you cannot select arbitrary track positions in script config, you will need to place marker signals at the end of each track.
Once done, for each alternate platform signal, simply activate the Altn platforms (assign altn platforms first, then stack) extension. In the new configuration section that got added, click on the Track waypoints field and select each marker track.
And that’s it. This script will now assign trains to alternates first, and only start stacking when every track is occupied.
The script also has a configurage Stacking distance: how much space there will be between stacked trains. 8 meters by default.