SCS2006: Non train events to set variables

anand99

New member
I am using SCS2006 to run AI trains in my session. I have a station with 6 platforms. When an AI train arrives at a signal outside the station I want it to be able to determine in a loop which platforms are available and which ones are occupied before using Path Set to the right platform.

The way I want to do this is to have a Yes/No variable for each platform that indicates if it is occupied or not. However, I don't want this variable to be set or unset by trains that arrive/leave the platform using On Trigger Enter/Leave because I would have to do this for every possible train that can arrive at the station. I would also have to do this for every possible train for every possible trigger. I would also not know which platform the train arrived at and is leaving from and which On Trigger to listen for. Basically doing this from each train seems very complex.

Is there a way to Set or Unset these variables on a scenario thread by detecting the presence of trains on a trigger or trackmark? If so, how would I make this run in a loop for the lifetime of my scenario. Is that even advisable? From what I understand scenario threads are non-train specific and there can be one dedicated to monitor these platform triggers. But how do I keep that thread going for the liftime of the scenario? Also even though scenario threads are non-trian specific it looks like On Trigger and On Trackmark are train specific and cannot be used in a scenario thread?

Any suggestions of how to approach this are greatly appreciated.
 
Last edited:
Hi anand99

Yeah SCS can be a bit log winded for setting up such a thing.

However don't dispear, in week a new Variable system package will be uploaded to the DLS allowing "Skip if" variable in the Driver command bar and this will easy allow you to do what you require and way more.

Cheers

Lots
 
Hi anand99

Yeah SCS can be a bit log winded for setting up such a thing.

However don't dispear, in week a new Variable system package will be uploaded to the DLS allowing "Skip if" variable in the Driver command bar and this will easy allow you to do what you require and way more.

Cheers

Lots

Lots,

Thanks for that. However, from what I understand about SCS2006, it is not possible to use other driver commands. The schedule for the train is setup using the SCS2006 rule. You can use other rules in your session that do not interfere with train operations, for ex, I was able to incorporate the invisible speed limit rule that allows an alternate speed limit for diverging track from a junction before the train arrives at the junction. SCS2006 comes with its own set of commands that you are limited to. I know there is a driver command called Drive To Trackmark List and Drive To Station that I believe allows you to enter a list of trackmarks or platforms that you can have the train navigate to. However, I cannot use that as part of SCS2006.

I have been trying to come up with a way, but it looks like a scenario thread cannot just sit there and listen for any events that occur. It has to listen for a particular event. Like the On Announce can listen for particular custom announcement like "Train arrived on Platform 1" to set a variable to indicate the platform is occupied, but there is no way for it to listen to multiple events like other platforms too. It is tied to a specific text. But someone managed to implement the driver commands above, so I am sure there must be a way to track this in a scenario thread rather than on a train thread.
 
Hi

Looking at the commands available in a scenario thread you can set or toggle a YES/NO variable by using an On Trackmark or On Trigger command. As you say though these two commands are train specific so you would have to have a list of every possible train for each trigger.

When I programmed something similar to this it was for a UK layout. Main line trains tend to use the same small group of platforms and commuter trains normally use a different group of platforms. I took advantage of this to reduce the amount of programming for each train depending on what type it was. In your example above it would reduce the amount of programming if you were able to do something similar.

As you mention, the problem for each train is knowing which platform it is at so that it can set the correct path back out again. I got round that by having an integer variable for each train which is set to a value corresponding to the platform number. This means that the train knows which platform it is at and can select the appropriate path out of the station by using If commands.

All the initial setting of variables was done in a scenario thread but all subsequent changes were made from the train thread when required as this seemed to be the best way of keeping track of what was doing what.

I hope that this is clear and of some help but if you require any clarification please post back.

Regards

Brian
 
Brian,

After your message, I realized the second part of the issue, which is that the train would need conditional paths out of the platform depending on which platform it pulled into.

But, coming back to the other issue, I don't necessarily want to place any restriction on which platform a train can pull into. If I did place an On Trigger command on a scenario thread, would it be the only command on that thread? Only then can it keep listening in a loop for the trigger to be fired right? So does that mean I would need one thread for each platform? Even if I had two On Trigger commands on the same scenario thread the second one would never reach until the first one was hit. I wonder if I would wind up creating too many scenario threads if I started down the path of making one thread per platform for each station on my route.

If I took the train approach, I could program in a massive If statement to both arrive and leave the platforms but I still don't want to release the platform until I am out of the station area. I suppose I could wait to hit a certain point outside the station and then clear the variable. It sounds complicated but it seems like your approach is the only feasible approach.

I also noticed that there is no thread safe way to set a variable. If two trains try to set a variable at exactly the same time they both get to set it. I implemented a crossover locking mechanism with a variable and if two trains arrive at the crossover at exactly the same time they both reset the variable and cross through each other. But if one train arrives 4 seconds later than the other one then everything works like a charm. One thing I wish SCS 2006 had was a way to start a thread and just keep listening for multiple events in parallel and handling any events in the order they are received.
 
Last edited:
Hi again

I've given a bit of thought to this problem and can't really see an advantageous way of doing what you want. The only possible way that I can see is to have separate looping scenario threads for each variable and perhaps use an On Announcement command in each thread. The downside is that each train would still need a list of If commands to be able to issue the correct announcement which negates any advantage gained from using this method.

If each train still needs a list of If commands to send the correct Announcement you may as well toggle or set the variables and set the correct path at the same time in the train thread. I don't know if you are aware that there is a limit to the number of threads that can be used in a scenario. Tests that I did last year showed that the limit was 56. If you use one scenario thread you have 55 available for train threads. If however you have 8 scenario threads you will only have 48 train threads available.

If you used an On Trigger or On Trackmark command as far as I can see you would have to have 6 scenario threads for each train to get it to work which would soon get out of hand.

There may be another solution to this problem and I will continue to give it some thought but nothing comes to mind immediately.

There is a new version (SCS2010?) in beta testing but I know that there have been problems with Auran changing the code in TS2010 SPs that have caused problems with the new version and this has caused the release to be postponed. I believe that this version will be much improved but I have no idea of if or when it will be released.



Regards

Brian
 
Hi again

I've given a bit of thought to this problem and can't really see an advantageous way of doing what you want. The only possible way that I can see is to have separate looping scenario threads for each variable and perhaps use an On Announcement command in each thread. The downside is that each train would still need a list of If commands to be able to issue the correct announcement which negates any advantage gained from using this method.

If each train still needs a list of If commands to send the correct Announcement you may as well toggle or set the variables and set the correct path at the same time in the train thread. I don't know if you are aware that there is a limit to the number of threads that can be used in a scenario. Tests that I did last year showed that the limit was 56. If you use one scenario thread you have 55 available for train threads. If however you have 8 scenario threads you will only have 48 train threads available.

If you used an On Trigger or On Trackmark command as far as I can see you would have to have 6 scenario threads for each train to get it to work which would soon get out of hand.

There may be another solution to this problem and I will continue to give it some thought but nothing comes to mind immediately.

There is a new version (SCS2010?) in beta testing but I know that there have been problems with Auran changing the code in TS2010 SPs that have caused problems with the new version and this has caused the release to be postponed. I believe that this version will be much improved but I have no idea of if or when it will be released.



Regards

Brian

Thanks Brian, I did not know they were working on a newer version. I hope they do release it. Notwithstanding some issues like this, I still think that it is the most powerful approach to controlling AI trains and making them do exactly what you want them to do. Takes some time programming in the commands though and the schedule does get pretty lengthy on each train. But then you end up with precise control on the train. Thanks for all your help.
 
Hello all, I am trying to get back into Trainz after taking a break of over 2 years. I want to get back into trying to use the SCS rule for my sessions. I was wondering if a newer version of SCS2006 has been released or if that never materialized. Are there any other rules or combination of commands that allow the type of control one had over a session when using the SCS2006 rule? I have been away so long I am completely out of touch, so any help is greatly appreciated!
 
Your best hope would be to try and get in touch with the author of SCS2006, Mike Carter (Thackalane). I think he still is active here. There has been no public release of a newer version but I have seen comments from testers about SCS for TS12.
William
 
Back
Top