Is there a way to add schedule commands from schedule library based on variable check

sauleve

New member
I'm new to Trainz and new to this session editing malarky but have dabbled with programming before. I'm playing with the roundhouse as a way of figuring out the pseudo programming of the surveyor.

I've got my turntable control just fine, and I can set up a static command list on my driver to drive up the roundhouse approach, onto the TT, rotate and back in to the bay.

Yay! but now I want more :-) ....

I have triggers set up on each of the roundhouse engine shed spurs so that as my trains go in from bay 1-7 a variable is incremented

baysfull=2 for example means that bays 1 and 2 are occupied.

Now on my arrival spur I have a trigger, and on arrival at the trigger I want to check the variable, and depending on the value pull a particular set of driver commands out of "schedule library" such that the engine gets directed into the next free bay.

The logic I'm after is

Trigger check
--->variable check //baysfull=0
-------->add commands to get to bay1 from schedule library
--->variable check //baysfull=1
-------->add commands to get to bay2 from schedule library
--->variable check //baysfull=2
-------->add commands to get to bay3 from schedule library
etc.

How do I go about adding the commands, there must be a rule I'm missing. "Copy commands from" works if I add manually within driver mode but is not an option in my edit session screen to do it in a "scripted" way.

any clues gratefully received.
 
Last edited:
Good idea - I too am learning about prototypical operations, and would like to automate as much as possible using the AI. The website
http://trains.0catch.com/tutorial.html
has good tutorials about using some of the downloadable assets for the AI.

But, is there more automatic scripting that can be done with the AI? For example, dispatching based on waybills? Or, is there any way to programmatically control switch lists?

This is actually a very fascinating area for me with the game - although my five year simply wants circles with a certain A10 running around it... :)
 
There are at least three approaches to programming in Trainz:

SCS (Scenario Creation System) available free of charge from the Trainz Pro Routes web site (in the forum I think). There are separate versions for TRS2004 and TRS2006. This is generally considered to be the easiest method.

TRS2004 scenarios, written in GameScript which is a C-like language. Tough going for non-programmers but capable of doing anything. The API is in C:\Program Files\Auran\TRS2004\Scripts\docs\index.chm and a step-by-step getting started tutorial is available here. This is what we use to create our activities, augmented by our own library functions.

Driver sessions, created in what amounts to an IDE in Surveyor. Very difficult to understand and to use if you want to do anything non-trivial, IMHO, and if no rule is available to perform an operation then you are sunk. The TRS2006 Rules And Sessions Guide provides some very useful information.

BTW, GameScript is also used to write the rules and driver commands used in sessions, and to control active assets such as loading-carry wagons, industries and animated scenery items. The TRS2006 version of the API is available here.

HTH, John
 
Is there a way to examine and edit the existing rules, I may be (remains to be seen) enough of a programmer to tweak an existing one to my needs.
 
If the rule's script file has an extension/file type of .gs you can edit it (subject of course to the usual etiquette considerations for editing someone else's content) but if it's gse then it's encrypted.

The TRS2004 GameScript API (and probably the TRS2006 version as well) has the source listings of the config.txt and .gs files for a number of built-in rules and driver commands, in the Asset Source section.

John
 
Thats very helpful John, thanks for taking the time. I only have TS 2009 so I cannot access the TRS2004 GameScript API, googling it draws a blank.

The route I am going for better or worse is rules in session editor because having had a look at it in notepad hand coding the game script is beyond me.

So all i need now is a rule that I can use a bit like ScheduleAtTrackMark, without the "at track mark" bit so i can run it after a variable test. The search continues ...
 
The route I am going for better or worse is rules in session editor
AFAIK that's the only option in TS2009 at the moment - unless anyone knows different of course.

In theory someone with enough knowledge can create a new rule but that level of programming is well beyond me. If that interests you, try the TRS2006 API which is downloadable.

John
 
Back
Top