HowTo/Create an Interactive Session
The Trainz "Session" concept is very powerful and yet also easy enough that anyone can create their own Sessions. The simplest Session involves adding consists to a route, assigning some AI orders, and setting a few basic startup settings for the session in the default rules.
This document is a quick introduction to sessions aimed at getting people to think beyond that most basic level, and to take advantage of the power and flexibility of the session concept.
It assumes you are familiar with Driver and basic Surveyor usage including placing scenery and trains. If you aren't familiar with these concepts, then you may need a more basic introduction to Trainz Driver and Surveyor and go through the HowTo/Create your first Session tutorial. For a more detailed look at Session Rules and how they operate, check out Session_Rules_Overview.
Creating an interactive session
You might be interested in our Twitch TV video tutorial HERE on session creation.
In the routes menu, find the route 'Springfield Industrial District' (you may have to unselect 'show only favorite routes'). This example uses this route because it's small, and it is built-in with Trainz 12. Show the sessions, and then click 'new session'.
Place a CHN ND5-1 on one of the turntable tracks, and a CHN G70K tanker in the yard next to the turntable.
Setting the initial startup options
Now open the 'Edit Session' dialog on the main menu. Change the session name and type something in for the description.
You should have something that looks roughly like this:
If you are using TS2010, remove the 'ConsistDataHandler' and 'QuickDrive' rules. Nice though they are, we don't want the player of this session to be able to arbitrarily create new vehicles. To delete the rule, click on it to select it, and then click the 'Delete' button.
Note: If you are using TS12, Trainz Simulator Mac, or later, then you won't have 'startup options' - 'QuickDrive' has taken over this role. So instead of deleting those two rules, edit the 'QuickDrive' rule (highlight it and click the 'Edit' button), and tick the "Gameplay Session" option in the QuickDrive options. Save the changes.
Adding a displayed score
Add the Display Custom HUD Rule - click 'add', find 'Display Custom HUD' in the list, select it, and click the tick button.
Add a Variable Modify Rule. Once you've added this, click the 'Edit' button, and you can set the rule properties. Anything you can click on is underlined. Click on 'Add', and set this to 'Change'. Also set the number to '0'. It should look like this:
Confirm these changes by clicking the tick button on the 'Properties' dialog.
Add a Variable Show Rule.
Checking the user makes a train correctly
Add a Consist Check Rule. Select 'Complete whenever a train matching the description exists'. This opens up several more options. Under 'Specific Vehicles', click the plus, and add our ND5. Repeat this and add the G70K as well. Also tick 'Enforce strict exclusive checking'. It should look like this:
'Enforce strict exclusive checking' will make the consist check rule check the consist more thoroughly - so if someone picks up too many vehicles in the yard, it won't trigger.
Confirm these changes by clicking the tick button on the 'Properties' dialog.
Finally, Add a 'Variable Modify' rule at the bottom, under 'Consist Check'. We will click the right arrow button once to indent the rule one level to the right.
This means this rule will not take effect immediately, but will be triggered by the 'Consist Check' rule, when the consist exists.
Now tick the 'Edit Session' dialog.
Driving your first session
Let's try this out in Driver now.
Click on the Driver button next to the main menu. Save the session. (If it asks to save the map, you've done something wrong - did you place the trains in the wrong layer?)
In Driver, you should see the 'Custom HUD' panel, and in it, an extra field labelled 'Score'. It should be zero. Take the ND5 over to the G70K tanker, and couple up to it. If the rules are set up right, 'Score' should change to '1'.
Adding a pickup task at an industry
Okay, let's take this a stage further. Go back to surveyor, and set the current layer to the session layer in the layers tab.
Configuring an industry
Configure 'Palmer Chemicals', by clicking on the industry track (between the two arrows) with the question mark icon from the 'scenery' tab. This is a 'multiple industry new' track. As this is a new session, it won't have any configuration yet - so we'll need to add some. See HowTo/Configure an Interactive Industry for details.
Checking the user uses the industry
Go back to the 'Edit Session' dialog. At the bottom, add a 'Resource Check' rule. Edit the resource check rule.
Pick the 'Watch Vehicle Queue' option. Within this, set 'CHN G70K Tanker' as the target object. Set the queue to be 'liquid' (there should be only one option). Set the product to be Aviation Fuel. Set the amount to be '72040' (you can actually type in '99999' and it'll autocorrect to the maximum size of the queue if it's larger than what the queue can hold). Ensure 'Complete when the designated queue equals or exceeds required amount' is set. It should look like this:
Tick the Properties dialog.
Now add a 'Variable Modify' rule below the Resource Check Rule, configure it to add one to the variable 'score', and indent it one step to the right. Your session rules should look like this:
Testing the extended session
Now let's try this out in Driver. Couple the ND5 to the tanker as before. The score should update to 1 when you do this. Now take the wagon up the hill to Palmer Chemicals.
Stop the wagon next to the three pink tanks, and wait for it to load. Once it is loaded, the score should update to 2.
Adding a delivery task at an industry
And another stage. Go back to surveyor, and reselect the session layer.
Go to the airport, and in it's properties, set it's Aviation Fuel queue to start at Zero and consume Zero.
Now in 'Edit Session', add another 'Resource Check' rule to the bottom of the list. Configure this one to watch an industry queue on 'Local Airport'. There will be several queues here - you want 'av_in_q', with product 'Aviation Fuel'. We're going to watch for 144000 units, and complete when the queue equals or exceeds the required amount.
It should look like this:
Underneath and indented beyond this, we're going to need another Variable Modify rule.
When we test this in Driver, we'll need to fill the tanker twice - and deliver two loads. Only at the second load will the score go to 3.
Checking vehicles are left in designated places
Penalising Passing Red Signals
click the add button in session rules and look for the rule "wait for derailment" add this in your session rules. this rule detects when a train derails then add a child rule end session since a derailment will mean the locomotive will no longer work end the session now
Adding a 'session complete' achievement
Hints and Tips
Some background information you may find useful.
TS2010 introduced the concept of layers to Trainz, and when working on a session, you will need to use them. The key thing is that this allows you to add most types of Trainz assets to the session, which previously could only be used in a route. As well as the usual Traincars, this can be scenery objects, trackside objects, even splines.
A good tip is to lock the route layer(s). This will help prevent accidental editing of the route layers.
Pay particular attention to layers if you use the 'quicklaunch' feature to launch Driver direct from Surveyor and return to Surveyor afterwards. The layer you had selected before probably won't still be selected afterwards, so you'll need to check it every time you return from Driver.
'Base session' assets
Some routes come with a 'base session'. This generally has pre-configured settings for industries and other scripted assets in it. You may find, should your chosen map depend heavily on multiple industry assets or other similar scripted content, that you may need to base your session on a 'base session' asset, rather than creating a new session.
In this case, the default rules list may differ - as it may have been created in a different version of Trainz, or the route creator may have decided to change a few things. Feel free to add any missing rules you want, or remove extras you don't.
In the 'Edit Session' dialog in TS2010, there are six rules by default.
- 'Startup Options Rule' - Sets the control mode for the session, the weather, the start time, and a few other bits and pieces.
- 'Driver Setup Rule' - Performs the assignment drivers to trains, and optionally gives those drivers AI orders.
- 'Driver Commands Rule' - Controls what orders can be assigned to AI drivers in the session.
- 'Clean up Derailed Trains Rule' - Will mop up derailed vehicles.
- 'ConsistDataHandler Rule' - Is used by QuickDrive to manage train placement (largely obsolete as of TS12).
- 'QuickDrive Rule' - Provides the quick drive interface that allows you to create consists and so on in Driver.
TS12 and Trainz Simulator Mac do not have 'Startup Options', 'QuickDrive' now performs that role.
As a general rule, for a pre-planned interactive session you probably don't want to permit the human driver to issue AI orders, or to be able to use the features of QuickDrive.
However, you probably want to be able to issue AI orders to background AI traffic while making the session, and you'll certainly need to fix those orders later if it turns out they don't quite do what you wanted them to. If you turn them off now, you'll have to turn them back on again when doing these operations - so my advice would be to only turn them off (by unticking them all) in 'Driver Commands' at the end of the creation process, once the session is finished. It will get too annoying to keep turning them on and off when you need to fix problems with the background AI otherwise.
With TS2010, QuickDrive will have to be removed from the rules list if you're worried about people using it to "cheat".
With TS12 and Trainz Mac, it is possible to disable the advanced features of QuickDrive, but still use it's better Cab/DCC mode selection screen - simply tick the 'Gameplay Session' checkbox in the QuickDrive options. This will deny the player access to the parts of QuickDrive which would cause problems in an interactive session.